feat(订单): 新增借还记录查询功能
添加借还记录查询相关接口及DTO,包括分页查询和状态筛选功能 扩展微信用户服务,支持根据ab98UserId查询所有关联用户 优化订单查询逻辑,支持多openid查询 新增数据库表结构定义文件
This commit is contained in:
parent
13ba9efe63
commit
cd9913419b
|
|
@ -39,7 +39,8 @@
|
||||||
"Bash(./mvnw clean compile -pl agileboot-domain -am -DskipTests)",
|
"Bash(./mvnw clean compile -pl agileboot-domain -am -DskipTests)",
|
||||||
"Bash(./mvnw:*)",
|
"Bash(./mvnw:*)",
|
||||||
"Bash(tree:*)",
|
"Bash(tree:*)",
|
||||||
"Bash(cat:*)"
|
"Bash(cat:*)",
|
||||||
|
"Bash(git checkout:*)"
|
||||||
],
|
],
|
||||||
"deny": [],
|
"deny": [],
|
||||||
"ask": []
|
"ask": []
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,9 @@ import com.agileboot.common.utils.poi.CustomExcelUtil;
|
||||||
import com.agileboot.domain.shop.order.OrderApplicationService;
|
import com.agileboot.domain.shop.order.OrderApplicationService;
|
||||||
import com.agileboot.domain.shop.order.db.ShopOrderEntity;
|
import com.agileboot.domain.shop.order.db.ShopOrderEntity;
|
||||||
import com.agileboot.domain.shop.order.db.dto.OrderWithGoodsDTO;
|
import com.agileboot.domain.shop.order.db.dto.OrderWithGoodsDTO;
|
||||||
|
import com.agileboot.domain.shop.order.dto.BorrowReturnRecordDTO;
|
||||||
import com.agileboot.domain.shop.order.dto.ShopOrderExcelDTO;
|
import com.agileboot.domain.shop.order.dto.ShopOrderExcelDTO;
|
||||||
|
import com.agileboot.domain.shop.order.query.SearchBorrowReturnRecordQuery;
|
||||||
import com.agileboot.domain.shop.order.query.SearchShopOrderExcelQuery;
|
import com.agileboot.domain.shop.order.query.SearchShopOrderExcelQuery;
|
||||||
import com.agileboot.domain.shop.order.query.SearchShopOrderQuery;
|
import com.agileboot.domain.shop.order.query.SearchShopOrderQuery;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
|
@ -53,4 +55,12 @@ public class ShopOrderController extends BaseController {
|
||||||
List<ShopOrderExcelDTO> excelDTOList = list.stream().map(ShopOrderExcelDTO::new).collect(Collectors.toList());
|
List<ShopOrderExcelDTO> excelDTOList = list.stream().map(ShopOrderExcelDTO::new).collect(Collectors.toList());
|
||||||
CustomExcelUtil.writeToResponse(excelDTOList, ShopOrderExcelDTO.class, response);
|
CustomExcelUtil.writeToResponse(excelDTOList, ShopOrderExcelDTO.class, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "借还记录分页列表")
|
||||||
|
@GetMapping("/borrow-return-record")
|
||||||
|
public ResponseDTO<PageDTO<BorrowReturnRecordDTO>> getBorrowReturnRecordList(SearchBorrowReturnRecordQuery<BorrowReturnRecordDTO> query) {
|
||||||
|
log.info("借还记录查询参数:{}", JSONUtil.toJsonStr(query));
|
||||||
|
PageDTO<BorrowReturnRecordDTO> page = orderApplicationService.getBorrowReturnRecordList(query);
|
||||||
|
return ResponseDTO.ok(page);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ public class WxController {
|
||||||
@GetMapping("/getWxUserByOpenid")
|
@GetMapping("/getWxUserByOpenid")
|
||||||
public ResponseDTO<WxUserDTO> getWxUserByOpenid(@RequestParam("openid") String openid) {
|
public ResponseDTO<WxUserDTO> getWxUserByOpenid(@RequestParam("openid") String openid) {
|
||||||
try {
|
try {
|
||||||
WxUserDTO wxUserDTO = wxUserApplicationService.getUserDetailByOpenid(openid);
|
WxUserDTO wxUserDTO = wxUserApplicationService.getOrCreateUserByOpenid(openid);
|
||||||
|
|
||||||
if (wxUserDTO == null) {
|
if (wxUserDTO == null) {
|
||||||
return ResponseDTO.fail(new ApiException(ErrorCode.Client.COMMON_REQUEST_PARAMETERS_INVALID, "用户不存在"));
|
return ResponseDTO.fail(new ApiException(ErrorCode.Client.COMMON_REQUEST_PARAMETERS_INVALID, "用户不存在"));
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,8 @@ import com.agileboot.domain.shop.goods.model.GoodsModel;
|
||||||
import com.agileboot.domain.shop.order.command.SubmitOrderCommand;
|
import com.agileboot.domain.shop.order.command.SubmitOrderCommand;
|
||||||
import com.agileboot.domain.shop.order.db.*;
|
import com.agileboot.domain.shop.order.db.*;
|
||||||
import com.agileboot.domain.shop.order.db.dto.OrderWithGoodsDTO;
|
import com.agileboot.domain.shop.order.db.dto.OrderWithGoodsDTO;
|
||||||
|
import com.agileboot.domain.shop.order.dto.BorrowReturnRecordDTO;
|
||||||
|
import com.agileboot.domain.shop.order.query.SearchBorrowReturnRecordQuery;
|
||||||
import com.agileboot.domain.shop.order.dto.CreateOrderResult;
|
import com.agileboot.domain.shop.order.dto.CreateOrderResult;
|
||||||
import com.agileboot.domain.shop.order.dto.GetOrdersByOpenIdDTO;
|
import com.agileboot.domain.shop.order.dto.GetOrdersByOpenIdDTO;
|
||||||
import com.agileboot.domain.shop.order.dto.TopGoodsDTO;
|
import com.agileboot.domain.shop.order.dto.TopGoodsDTO;
|
||||||
|
|
@ -109,6 +111,11 @@ public class OrderApplicationService {
|
||||||
return new PageDTO<>(page.getRecords(), page.getTotal());
|
return new PageDTO<>(page.getRecords(), page.getTotal());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PageDTO<BorrowReturnRecordDTO> getBorrowReturnRecordList(SearchBorrowReturnRecordQuery<BorrowReturnRecordDTO> query) {
|
||||||
|
Page<BorrowReturnRecordDTO> page = orderService.getBorrowReturnRecordList(query);
|
||||||
|
return new PageDTO<>(page.getRecords(), page.getTotal());
|
||||||
|
}
|
||||||
|
|
||||||
public List<ShopOrderEntity> list(SearchShopOrderExcelQuery<ShopOrderEntity> query) {
|
public List<ShopOrderEntity> list(SearchShopOrderExcelQuery<ShopOrderEntity> query) {
|
||||||
return orderService.list(query.toQueryWrapper());
|
return orderService.list(query.toQueryWrapper());
|
||||||
}
|
}
|
||||||
|
|
@ -448,21 +455,40 @@ public class OrderApplicationService {
|
||||||
// 根据 openid 获取 Ab98 用户信息
|
// 根据 openid 获取 Ab98 用户信息
|
||||||
Ab98UserEntity ab98User = ab98UserService.getByOpenid(openid);
|
Ab98UserEntity ab98User = ab98UserService.getByOpenid(openid);
|
||||||
|
|
||||||
|
if (ab98User == null) {
|
||||||
|
WxUserEntity wxUser = wxUserService.getByOpenid(openid);
|
||||||
|
if (wxUser != null && wxUser.getAb98UserId() != null) {
|
||||||
|
ab98User = ab98UserService.getById(wxUser.getAb98UserId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> openidList;
|
||||||
|
if (ab98User != null) {
|
||||||
|
openidList = wxUserService.getAllByAb98UserId(ab98User.getAb98UserId()).stream().map(WxUserEntity::getOpenid).collect(Collectors.toList());
|
||||||
|
} else {
|
||||||
|
openidList = null;
|
||||||
|
}
|
||||||
|
|
||||||
// 构建订单查询条件
|
// 构建订单查询条件
|
||||||
QueryWrapper<ShopOrderEntity> orderQueryWrapper = new QueryWrapper<>();
|
QueryWrapper<ShopOrderEntity> orderQueryWrapper = new QueryWrapper<>();
|
||||||
// 添加 openid 作为查询条件
|
// 添加 openid 作为查询条件
|
||||||
|
Ab98UserEntity finalAb98User = ab98User;
|
||||||
orderQueryWrapper.and(wrapper -> {
|
orderQueryWrapper.and(wrapper -> {
|
||||||
|
if (openidList != null && !openidList.isEmpty()) {
|
||||||
|
wrapper.in("openid", openidList);
|
||||||
|
} else {
|
||||||
wrapper.eq("openid", openid);
|
wrapper.eq("openid", openid);
|
||||||
|
}
|
||||||
// 如果 Ab98 用户信息存在
|
// 如果 Ab98 用户信息存在
|
||||||
if (ab98User != null) {
|
if (finalAb98User != null) {
|
||||||
// 添加 or 条件,根据 Ab98 用户的 userid 查询订单
|
// 添加 or 条件,根据 Ab98 用户的 userid 查询订单
|
||||||
wrapper.or()
|
wrapper.or()
|
||||||
.eq("userid", ab98User.getUserid());
|
.eq("userid", finalAb98User.getUserid());
|
||||||
|
|
||||||
// 如果 corpid 不为空
|
// 如果 corpid 不为空
|
||||||
if (StringUtils.isNotBlank(corpid)) {
|
if (StringUtils.isNotBlank(corpid)) {
|
||||||
// 根据 Ab98 用户的 ab98UserId 和 corpid 获取企业微信用户信息
|
// 根据 Ab98 用户的 ab98UserId 和 corpid 获取企业微信用户信息
|
||||||
QyUserEntity qyUser = qyUserService.getUserByAb98UserId(ab98User.getAb98UserId(), corpid);
|
QyUserEntity qyUser = qyUserService.getUserByAb98UserId(finalAb98User.getAb98UserId(), corpid);
|
||||||
// 如果企业微信用户信息存在
|
// 如果企业微信用户信息存在
|
||||||
if (qyUser!= null) {
|
if (qyUser!= null) {
|
||||||
// 添加 or 条件,根据企业微信用户的 userid 查询订单
|
// 添加 or 条件,根据企业微信用户的 userid 查询订单
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
package com.agileboot.domain.shop.order.db;
|
package com.agileboot.domain.shop.order.db;
|
||||||
|
|
||||||
import com.agileboot.domain.shop.order.db.dto.OrderWithGoodsDTO;
|
import com.agileboot.domain.shop.order.db.dto.OrderWithGoodsDTO;
|
||||||
|
import com.agileboot.domain.shop.order.dto.BorrowReturnRecordDTO;
|
||||||
|
import com.agileboot.domain.shop.order.query.SearchBorrowReturnRecordQuery;
|
||||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||||
|
|
@ -33,6 +35,37 @@ public interface ShopOrderMapper extends BaseMapper<ShopOrderEntity> {
|
||||||
@Param(Constants.WRAPPER) Wrapper<OrderWithGoodsDTO> queryWrapper
|
@Param(Constants.WRAPPER) Wrapper<OrderWithGoodsDTO> queryWrapper
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@Select("<script>" +
|
||||||
|
"SELECT " +
|
||||||
|
"so.order_id as orderId, " +
|
||||||
|
"ra.approval_id as approvalId, " +
|
||||||
|
"so.create_time as orderTime, " +
|
||||||
|
"ra.return_images as returnImages, " +
|
||||||
|
"ra.audit_images as auditImages, " +
|
||||||
|
"sog.price as goodsPrice, " +
|
||||||
|
"so.payment_method as paymentMethod, " +
|
||||||
|
"so.name as orderName, " +
|
||||||
|
"so.mobile as orderMobile, " +
|
||||||
|
"sog.quantity as quantity, " +
|
||||||
|
"ra.audit_name as auditName, " +
|
||||||
|
"ra.audit_remark as auditRemark, " +
|
||||||
|
"CASE " +
|
||||||
|
" WHEN ra.approval_id IS NULL THEN 0 " +
|
||||||
|
" WHEN ra.status IN (1, 4) THEN 1 " +
|
||||||
|
" WHEN ra.status = 2 THEN 2 " +
|
||||||
|
" WHEN ra.status = 3 THEN 3 " +
|
||||||
|
" ELSE -1 " +
|
||||||
|
"END as status " +
|
||||||
|
"FROM shop_order so " +
|
||||||
|
"INNER JOIN shop_order_goods sog ON so.order_id = sog.order_id AND sog.deleted = 0 " +
|
||||||
|
"LEFT JOIN return_approval ra ON sog.order_goods_id = ra.order_goods_id AND ra.deleted = 0 " +
|
||||||
|
"${ew.customSqlSegment}" +
|
||||||
|
"</script>")
|
||||||
|
Page<BorrowReturnRecordDTO> getBorrowReturnRecordList(
|
||||||
|
Page<BorrowReturnRecordDTO> page,
|
||||||
|
@Param(Constants.WRAPPER) Wrapper<BorrowReturnRecordDTO> queryWrapper
|
||||||
|
);
|
||||||
|
|
||||||
@Select("SELECT COUNT(1) FROM shop_order WHERE deleted = 0")
|
@Select("SELECT COUNT(1) FROM shop_order WHERE deleted = 0")
|
||||||
Long countAllRecord();
|
Long countAllRecord();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
package com.agileboot.domain.shop.order.db;
|
package com.agileboot.domain.shop.order.db;
|
||||||
|
|
||||||
import com.agileboot.domain.shop.order.db.dto.OrderWithGoodsDTO;
|
import com.agileboot.domain.shop.order.db.dto.OrderWithGoodsDTO;
|
||||||
|
import com.agileboot.domain.shop.order.dto.BorrowReturnRecordDTO;
|
||||||
|
import com.agileboot.domain.shop.order.query.SearchBorrowReturnRecordQuery;
|
||||||
import com.agileboot.domain.shop.order.query.SearchShopOrderQuery;
|
import com.agileboot.domain.shop.order.query.SearchShopOrderQuery;
|
||||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
|
@ -19,6 +21,8 @@ import java.math.BigDecimal;
|
||||||
public interface ShopOrderService extends IService<ShopOrderEntity> {
|
public interface ShopOrderService extends IService<ShopOrderEntity> {
|
||||||
Page<OrderWithGoodsDTO> getOrderList(SearchShopOrderQuery<OrderWithGoodsDTO> query);
|
Page<OrderWithGoodsDTO> getOrderList(SearchShopOrderQuery<OrderWithGoodsDTO> query);
|
||||||
|
|
||||||
|
Page<BorrowReturnRecordDTO> getBorrowReturnRecordList(SearchBorrowReturnRecordQuery<BorrowReturnRecordDTO> query);
|
||||||
|
|
||||||
Long countAllRecord();
|
Long countAllRecord();
|
||||||
|
|
||||||
BigDecimal sumTotalAmount();
|
BigDecimal sumTotalAmount();
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,10 @@ package com.agileboot.domain.shop.order.db;
|
||||||
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import com.agileboot.domain.shop.order.db.dto.OrderWithGoodsDTO;
|
import com.agileboot.domain.shop.order.db.dto.OrderWithGoodsDTO;
|
||||||
|
import com.agileboot.domain.shop.order.dto.BorrowReturnRecordDTO;
|
||||||
import com.agileboot.domain.shop.order.model.OrderModel;
|
import com.agileboot.domain.shop.order.model.OrderModel;
|
||||||
import com.agileboot.domain.shop.order.query.SearchShopOrderQuery;
|
import com.agileboot.domain.shop.order.query.SearchShopOrderQuery;
|
||||||
|
import com.agileboot.domain.shop.order.query.SearchBorrowReturnRecordQuery;
|
||||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||||
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;
|
||||||
|
|
@ -26,6 +28,11 @@ public class ShopOrderServiceImpl extends ServiceImpl<ShopOrderMapper, ShopOrder
|
||||||
return baseMapper.getOrderList(query.toPage(), query.toQueryWrapper());
|
return baseMapper.getOrderList(query.toPage(), query.toQueryWrapper());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<BorrowReturnRecordDTO> getBorrowReturnRecordList(SearchBorrowReturnRecordQuery<BorrowReturnRecordDTO> query) {
|
||||||
|
return baseMapper.getBorrowReturnRecordList(query.toPage(), query.toQueryWrapper());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long countAllRecord() {
|
public Long countAllRecord() {
|
||||||
return baseMapper.countAllRecord();
|
return baseMapper.countAllRecord();
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,64 @@
|
||||||
|
package com.agileboot.domain.shop.order.dto;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class BorrowReturnRecordDTO {
|
||||||
|
|
||||||
|
@ApiModelProperty("订单ID")
|
||||||
|
private Long orderId;
|
||||||
|
|
||||||
|
@ApiModelProperty("审批ID")
|
||||||
|
private Long approvalId;
|
||||||
|
|
||||||
|
@ApiModelProperty("订单创建时间")
|
||||||
|
private Date orderTime;
|
||||||
|
|
||||||
|
@ApiModelProperty("归还图片")
|
||||||
|
private String returnImages;
|
||||||
|
|
||||||
|
@ApiModelProperty("审核图片")
|
||||||
|
private String auditImages;
|
||||||
|
|
||||||
|
@ApiModelProperty("订单商品价格")
|
||||||
|
private BigDecimal goodsPrice;
|
||||||
|
|
||||||
|
@ApiModelProperty("支付方式")
|
||||||
|
private String paymentMethod;
|
||||||
|
|
||||||
|
@ApiModelProperty("订单姓名")
|
||||||
|
private String orderName;
|
||||||
|
|
||||||
|
@ApiModelProperty("订单手机号")
|
||||||
|
private String orderMobile;
|
||||||
|
|
||||||
|
@ApiModelProperty("订单商品数量")
|
||||||
|
private Integer quantity;
|
||||||
|
|
||||||
|
@ApiModelProperty("审批人")
|
||||||
|
private String auditName;
|
||||||
|
|
||||||
|
@ApiModelProperty("审核说明")
|
||||||
|
private String auditRemark;
|
||||||
|
|
||||||
|
@ApiModelProperty("状态(0未退还 1待审批 2已通过 3已驳回)")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
@ApiModelProperty("状态描述")
|
||||||
|
private String statusStr;
|
||||||
|
|
||||||
|
public String getStatusStr() {
|
||||||
|
if (status == null) return "-";
|
||||||
|
switch (status) {
|
||||||
|
case 0: return "未退还";
|
||||||
|
case 1: return "待审批";
|
||||||
|
case 2: return "已通过";
|
||||||
|
case 3: return "已驳回";
|
||||||
|
default: return "未知状态";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
package com.agileboot.domain.shop.order.query;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.agileboot.common.core.page.AbstractPageQuery;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import java.util.Date;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
public class SearchBorrowReturnRecordQuery<T> extends AbstractPageQuery<T> {
|
||||||
|
|
||||||
|
private Long goodsId;
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public QueryWrapper<T> addQueryCondition() {
|
||||||
|
QueryWrapper<T> queryWrapper = new QueryWrapper<>();
|
||||||
|
|
||||||
|
if (status == null || status == 0) {
|
||||||
|
// 未退还:已支付但没有审批记录的订单商品
|
||||||
|
queryWrapper.eq("so.pay_status", 2)
|
||||||
|
.isNull("ra.approval_id");
|
||||||
|
} else if (status == 1) {
|
||||||
|
// 待审批:有审批记录且状态为1(待审核)或4(开柜中)的订单
|
||||||
|
queryWrapper.eq("ra.status", 1)
|
||||||
|
.or()
|
||||||
|
.eq("ra.status", 4);
|
||||||
|
} else if (status == 2) {
|
||||||
|
// 已通过:状态为2(已通过)的审批记录
|
||||||
|
queryWrapper.eq("ra.status", 2);
|
||||||
|
} else if (status == 3) {
|
||||||
|
// 已驳回:状态为3(已驳回)的审批记录
|
||||||
|
queryWrapper.eq("ra.status", 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (goodsId != null) {
|
||||||
|
queryWrapper.eq("sog.goods_id", goodsId);
|
||||||
|
}
|
||||||
|
|
||||||
|
queryWrapper.eq("so.deleted", 0)
|
||||||
|
.eq("sog.deleted", 0)
|
||||||
|
.orderByDesc("so.create_time");
|
||||||
|
|
||||||
|
return queryWrapper;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -4,6 +4,8 @@ import com.agileboot.common.core.page.AbstractPageQuery;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 微信用户信息表 服务类
|
* 微信用户信息表 服务类
|
||||||
*
|
*
|
||||||
|
|
@ -70,4 +72,12 @@ public interface WxUserService extends IService<WxUserEntity> {
|
||||||
* @return 微信用户信息
|
* @return 微信用户信息
|
||||||
*/
|
*/
|
||||||
WxUserEntity getByAb98UserId(Long ab98UserId);
|
WxUserEntity getByAb98UserId(Long ab98UserId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据ab98UserId获取所有微信用户
|
||||||
|
*
|
||||||
|
* @param ab98UserId 汇邦云用户ID
|
||||||
|
* @return 微信用户信息集合
|
||||||
|
*/
|
||||||
|
List<WxUserEntity> getAllByAb98UserId(Long ab98UserId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,9 @@ import com.agileboot.domain.wx.user.db.WxUserService;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
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.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
@ -111,4 +114,17 @@ public class WxUserServiceImpl extends ServiceImpl<WxUserMapper, WxUserEntity> i
|
||||||
|
|
||||||
return this.getOne(wrapper);
|
return this.getOne(wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<WxUserEntity> getAllByAb98UserId(Long ab98UserId) {
|
||||||
|
if (ab98UserId == null) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
LambdaQueryWrapper<WxUserEntity> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(WxUserEntity::getAb98UserId, ab98UserId)
|
||||||
|
.eq(WxUserEntity::getDeleted, 0);
|
||||||
|
|
||||||
|
return this.list(wrapper);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,139 @@
|
||||||
|
-- wxshop.shop_goods definition
|
||||||
|
|
||||||
|
CREATE TABLE `shop_goods` (
|
||||||
|
`goods_id` bigint NOT NULL AUTO_INCREMENT COMMENT '商品唯一ID',
|
||||||
|
`goods_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '商品名称',
|
||||||
|
`category_id` bigint NOT NULL COMMENT '商品分类ID',
|
||||||
|
`external_goods_id` bigint DEFAULT NULL COMMENT '外部归属类型的商品ID',
|
||||||
|
`corpid` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '企业微信id',
|
||||||
|
`monthly_purchase_limit` int DEFAULT NULL COMMENT '每人每月限购数量',
|
||||||
|
`belong_type` tinyint NOT NULL DEFAULT '0' COMMENT '归属类型(0-借还柜 1-固资通)',
|
||||||
|
`price` decimal(15,2) NOT NULL DEFAULT '0.00' COMMENT '销售价格',
|
||||||
|
`stock` int NOT NULL DEFAULT '0' COMMENT '库存数量',
|
||||||
|
`status` tinyint NOT NULL DEFAULT '2' COMMENT '商品状态(1上架 2下架)',
|
||||||
|
`auto_approval` tinyint NOT NULL DEFAULT '0' COMMENT '免审批(0否 1是)',
|
||||||
|
`cover_img` varchar(512) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '封面图URL',
|
||||||
|
`goods_detail` text COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '商品详情(支持2000汉字+10个图片链接)',
|
||||||
|
`usage_instruction` varchar(512) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '商品使用说明',
|
||||||
|
`creator_id` bigint NOT NULL DEFAULT '0' COMMENT '创建者ID',
|
||||||
|
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
|
`updater_id` bigint NOT NULL DEFAULT '0' COMMENT '更新者ID',
|
||||||
|
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||||
|
`remark` varchar(512) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '备注',
|
||||||
|
`deleted` tinyint(1) NOT NULL DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
|
||||||
|
PRIMARY KEY (`goods_id`),
|
||||||
|
KEY `idx_category` (`category_id`),
|
||||||
|
KEY `idx_status` (`status`),
|
||||||
|
KEY `idx_update_time` (`update_time`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=289 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='商品信息表';
|
||||||
|
|
||||||
|
|
||||||
|
-- wxshop.shop_order definition
|
||||||
|
|
||||||
|
CREATE TABLE `shop_order` (
|
||||||
|
`order_id` bigint NOT NULL AUTO_INCREMENT COMMENT '订单唯一ID',
|
||||||
|
`ucid` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'ucid',
|
||||||
|
`openid` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'openid',
|
||||||
|
`trade_id` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '支付网关交易id',
|
||||||
|
`mobile` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '手机号码',
|
||||||
|
`name` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '成员名称',
|
||||||
|
`ab98_user_id` bigint DEFAULT NULL COMMENT '汇邦云用户ID',
|
||||||
|
`userid` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '企业微信用户ID或汇邦云用户ID',
|
||||||
|
`biz_order_id` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '业务系统订单ID(对接外部系统)',
|
||||||
|
`total_amount` decimal(15,2) NOT NULL COMMENT '订单总金额',
|
||||||
|
`status` tinyint NOT NULL DEFAULT '1' COMMENT '订单状态(1待付款 2已付款 3已发货 4已完成 5已取消)',
|
||||||
|
`mode` tinyint NOT NULL DEFAULT '0' COMMENT '运行模式(0-支付模式 1-审批模式 2-借还模式 3-会员模式 4-耗材模式)',
|
||||||
|
`pay_status` tinyint NOT NULL DEFAULT '1' COMMENT '支付状态(1未支付 2已支付 3退款中 4已退款)',
|
||||||
|
`is_deduct_stock` tinyint NOT NULL DEFAULT '0' COMMENT '已扣减库存(0否 1是)',
|
||||||
|
`payment_method` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '支付方式',
|
||||||
|
`pay_time` datetime DEFAULT NULL COMMENT '支付时间',
|
||||||
|
`creator_id` bigint NOT NULL DEFAULT '0' COMMENT '创建者ID',
|
||||||
|
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
|
`updater_id` bigint NOT NULL DEFAULT '0' COMMENT '更新者ID',
|
||||||
|
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||||
|
`deleted` tinyint(1) NOT NULL DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
|
||||||
|
`is_internal` tinyint(1) DEFAULT '0' COMMENT '是否内部用户(0否 1汇邦云用户 2企业微信用户)',
|
||||||
|
`corpid` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '企业微信id',
|
||||||
|
PRIMARY KEY (`order_id`),
|
||||||
|
KEY `idx_status` (`status`),
|
||||||
|
KEY `idx_pay_status` (`pay_status`),
|
||||||
|
KEY `idx_create_time` (`create_time`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=1356 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='商品订单表';
|
||||||
|
|
||||||
|
|
||||||
|
-- wxshop.shop_order_goods definition
|
||||||
|
|
||||||
|
CREATE TABLE `shop_order_goods` (
|
||||||
|
`order_goods_id` bigint NOT NULL AUTO_INCREMENT COMMENT '订单商品唯一ID',
|
||||||
|
`order_id` bigint NOT NULL COMMENT '关联订单ID',
|
||||||
|
`approval_id` bigint DEFAULT NULL COMMENT '审批ID',
|
||||||
|
`goods_id` bigint DEFAULT NULL COMMENT '关联商品ID',
|
||||||
|
`cell_id` bigint DEFAULT NULL COMMENT '格口ID',
|
||||||
|
`quantity` int NOT NULL DEFAULT '1' COMMENT '购买数量',
|
||||||
|
`price` decimal(15,2) NOT NULL COMMENT '购买时单价',
|
||||||
|
`total_amount` decimal(15,2) NOT NULL COMMENT '商品总金额',
|
||||||
|
`status` tinyint NOT NULL DEFAULT '1' COMMENT '商品状态(1正常 2已退货 3已换货)',
|
||||||
|
`mode` tinyint NOT NULL DEFAULT '0' COMMENT '运行模式(0-支付模式 1-审批模式 2-借还模式 3-会员模式 4-耗材模式)',
|
||||||
|
`creator_id` bigint NOT NULL DEFAULT '0' COMMENT '创建者ID',
|
||||||
|
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
|
`updater_id` bigint NOT NULL DEFAULT '0' COMMENT '更新者ID',
|
||||||
|
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||||
|
`deleted` tinyint(1) NOT NULL DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
|
||||||
|
`goods_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '商品名称',
|
||||||
|
`cover_img` varchar(512) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '封面图URL',
|
||||||
|
`corpid` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '企业微信id',
|
||||||
|
PRIMARY KEY (`order_goods_id`),
|
||||||
|
KEY `idx_order` (`order_id`),
|
||||||
|
KEY `idx_goods` (`goods_id`),
|
||||||
|
KEY `idx_status` (`status`),
|
||||||
|
KEY `idx_create_time` (`create_time`),
|
||||||
|
CONSTRAINT `fk_order_goods_goods` FOREIGN KEY (`goods_id`) REFERENCES `shop_goods` (`goods_id`),
|
||||||
|
CONSTRAINT `fk_order_goods_order` FOREIGN KEY (`order_id`) REFERENCES `shop_order` (`order_id`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=1358 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='订单商品明细表';
|
||||||
|
|
||||||
|
|
||||||
|
-- wxshop.return_approval definition
|
||||||
|
|
||||||
|
CREATE TABLE `return_approval` (
|
||||||
|
`approval_id` bigint NOT NULL AUTO_INCREMENT COMMENT '审批编号',
|
||||||
|
`order_id` bigint DEFAULT NULL COMMENT '关联订单ID',
|
||||||
|
`goods_id` bigint DEFAULT NULL COMMENT '关联商品ID',
|
||||||
|
`order_goods_id` bigint DEFAULT NULL COMMENT '关联订单商品ID',
|
||||||
|
`approval_type` tinyint NOT NULL DEFAULT '0' COMMENT '审批类型(0为借还柜 1为固资通)',
|
||||||
|
`external_goods_id` bigint DEFAULT NULL COMMENT '外部归属类型的商品ID',
|
||||||
|
`external_approval_id` bigint DEFAULT NULL COMMENT '外部归属类型的审批ID',
|
||||||
|
`code` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '审批码',
|
||||||
|
`code_check` tinyint NOT NULL DEFAULT '0' COMMENT '审批码校验 0未核销 1已核销',
|
||||||
|
`corpid` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '企业微信id',
|
||||||
|
`audit_userid` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '审批人企业UserID',
|
||||||
|
`apply_userid` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '申请人企业UserID',
|
||||||
|
`apply_user_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '申请人',
|
||||||
|
`apply_quantity` int DEFAULT NULL COMMENT '申请数量',
|
||||||
|
`return_quantity` int DEFAULT NULL COMMENT '归还数量',
|
||||||
|
`goods_price` decimal(15,2) DEFAULT NULL COMMENT '商品单价',
|
||||||
|
`return_amount` decimal(15,2) DEFAULT NULL COMMENT '退还金额',
|
||||||
|
`return_images` varchar(2048) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '归还图片路径数组',
|
||||||
|
`audit_images` varchar(2048) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '审核图片路径数组',
|
||||||
|
`return_remark` varchar(1024) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '归还说明',
|
||||||
|
`apply_remark` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '申请说明',
|
||||||
|
`audit_remark` varchar(1024) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '审核说明',
|
||||||
|
`audit_name` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '审批人',
|
||||||
|
`status` tinyint NOT NULL DEFAULT '1' COMMENT '审批状态(1待审核 2已通过 3已驳回)',
|
||||||
|
`approval_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '审批时间',
|
||||||
|
`creator_id` bigint DEFAULT '0' COMMENT '创建者ID',
|
||||||
|
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
|
`updater_id` bigint DEFAULT '0' COMMENT '更新者ID',
|
||||||
|
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||||
|
`deleted` tinyint(1) NOT NULL DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
|
||||||
|
PRIMARY KEY (`approval_id`),
|
||||||
|
KEY `idx_order` (`order_id`),
|
||||||
|
KEY `idx_goods` (`goods_id`),
|
||||||
|
KEY `idx_status` (`status`),
|
||||||
|
KEY `idx_order_goods` (`order_goods_id`),
|
||||||
|
KEY `idx_external_goods_id` (`external_goods_id`),
|
||||||
|
KEY `idx_approval_type` (`approval_type`),
|
||||||
|
KEY `idx_external_approval_id` (`external_approval_id`),
|
||||||
|
CONSTRAINT `fk_return_goods` FOREIGN KEY (`goods_id`) REFERENCES `shop_goods` (`goods_id`),
|
||||||
|
CONSTRAINT `fk_return_order` FOREIGN KEY (`order_id`) REFERENCES `shop_order` (`order_id`),
|
||||||
|
CONSTRAINT `fk_return_order_goods` FOREIGN KEY (`order_goods_id`) REFERENCES `shop_order_goods` (`order_goods_id`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=1448 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='商品归还审批表';
|
||||||
Loading…
Reference in New Issue