Compare commits

...

3 Commits

Author SHA1 Message Date
dzq f33f74b20a feat(订单/格口): 新增订单与格口的关联查询功能
新增OrderWithGoodsDTO和CabinetCellWithOrderCountDTO,用于查询订单与商品信息及格口与订单数量的关联数据。修改相关Service、Mapper和Controller,支持分页查询订单列表和格口列表时返回关联信息。优化查询条件,增加订单ID和格口ID的过滤条件。
2025-04-26 07:58:45 +08:00
dzq ec7c3e5aa5 refactor(QywxScheduleJob): 优化用户信息同步逻辑
移除冗余的用户列表查询和删除用户逻辑,简化代码结构并提高执行效率
2025-04-25 15:21:47 +08:00
dzq 1945cb1787 feat(商品): 添加获取单个商品信息功能
新增获取单个商品信息的接口,包括在GoodsApplicationService、ShopGoodsService、ShopGoodsServiceImpl、ShopGoodsMapper中实现相关逻辑,并在ShopGoodsController中提供对外接口。

feat(支付日志): 添加支付操作日志记录功能

在支付回调、退款回调、提交订单、创建订单、退款等操作中添加支付操作日志记录功能,记录操作类型、状态、参数等信息,便于后续追踪和分析。
2025-04-25 11:42:23 +08:00
27 changed files with 289 additions and 43 deletions

View File

@ -14,20 +14,13 @@ import io.swagger.v3.oas.annotations.Operation;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RestController;
import com.agileboot.common.core.base.BaseController;
import com.agileboot.domain.shop.goods.command.AddGoodsCommand;
import com.agileboot.domain.shop.goods.command.UpdateGoodsCommand;
import javax.validation.constraints.NotNull;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
/**
* <p>
@ -83,5 +76,16 @@ public class ShopGoodsController extends BaseController {
goodsApplicationService.updateGoods(command);
return ResponseDTO.ok();
}
/**
* 获取单个商品信息
*/
@Operation(summary = "商品列表")
// @PreAuthorize("@permission.has('shop:goods:list')")
@GetMapping("/getGoodsInfo")
public ResponseDTO<ShopGoodsDTO> getGoodsInfo(@RequestParam Long goodsId) {
ShopGoodsDTO goodsInfo = goodsApplicationService.getGoodsInfo(goodsId);
return ResponseDTO.ok(goodsInfo);
}
}

View File

@ -9,6 +9,7 @@ import com.agileboot.common.enums.common.BusinessTypeEnum;
import com.agileboot.common.utils.poi.CustomExcelUtil;
import com.agileboot.domain.shop.order.OrderApplicationService;
import com.agileboot.domain.shop.order.db.ShopOrderEntity;
import com.agileboot.domain.shop.order.db.dto.OrderWithGoodsDTO;
import com.agileboot.domain.shop.order.dto.ShopOrderExcelDTO;
import com.agileboot.domain.shop.order.query.SearchShopOrderQuery;
import io.swagger.v3.oas.annotations.Operation;
@ -35,9 +36,9 @@ public class ShopOrderController extends BaseController {
@Operation(summary = "订单列表")
// @PreAuthorize("@permission.has('shop:goods:list')")
@GetMapping("/list")
public ResponseDTO<PageDTO<ShopOrderEntity>> list(SearchShopOrderQuery<ShopOrderEntity> query) {
public ResponseDTO<PageDTO<OrderWithGoodsDTO>> list(SearchShopOrderQuery<OrderWithGoodsDTO> query) {
log.info("订单列表查询参数:{}", JSONUtil.toJsonStr(query));
PageDTO<ShopOrderEntity> page = orderApplicationService.getOrderList(query);
PageDTO<OrderWithGoodsDTO> page = orderApplicationService.getOrderList(query);
return ResponseDTO.ok(page);
}

View File

@ -411,13 +411,6 @@ public class QywxScheduleJob {
.filter(d -> Objects.equals(d.getCorpid(), authCorpInfo.getCorpid()))
.collect(Collectors.toList());
List<QyUserEntity> qyUserList = qyUserApplicationService.selectAll();
if (null == qyUserList) {
qyUserList = new ArrayList<>();
}
qyUserList = qyUserList.stream()
.filter(u -> u.getCorpid().equals(authCorpInfo.getCorpid()))
.collect(Collectors.toList());
for (QyDepartmentEntity department : departmentList) {
// 获取部门用户列表
@ -440,26 +433,29 @@ public class QywxScheduleJob {
Map<String, UserListResponse.UserInfo> wxUserMap = wxUsers.stream()
.collect(Collectors.toMap(UserListResponse.UserInfo::getUserid, Function.identity()));
List<QyUserEntity> localUsers = qyUserList.stream()
.filter(u -> u.getAppid().equals(appid))
.collect(Collectors.toList());
Map<String, QyUserEntity> localUserMap = localUsers.stream()
.collect(Collectors.toMap(QyUserEntity::getUserid, Function.identity()));
List<QyUserEntity> qyUserList = qyUserApplicationService.selectAll();
if (null == qyUserList) {
qyUserList = new ArrayList<>();
}
qyUserList = qyUserList.stream()
.filter(u -> u.getCorpid().equals(authCorpInfo.getCorpid()) && u.getAppid().equals(appid))
.collect(Collectors.toList());
// 识别需要新增的用户
List<QyUserEntity> finalQyUserList = qyUserList;
List<UserListResponse.UserInfo> toAdd = wxUsers.stream()
.filter(wxUser -> !localUserMap.containsKey(wxUser.getUserid()))
.filter(wxUser -> finalQyUserList.stream().noneMatch(u -> u.getUserid().equals(wxUser.getUserid())))
.collect(Collectors.toList());
log.info("syncUserInfo toAdd: {}", JSONUtil.toJsonStr(toAdd));
// 识别需要删除的用户
List<QyUserEntity> toRemove = localUsers.stream()
/* List<QyUserEntity> toRemove = qyUserList.stream()
.filter(localUser -> !wxUserMap.containsKey(localUser.getUserid()))
.collect(Collectors.toList());
log.info("syncUserInfo toRemove: {}", JSONUtil.toJsonStr(toRemove));
log.info("syncUserInfo toRemove: {}", JSONUtil.toJsonStr(toRemove));*/
// 识别需要更新的用户
List<UpdateQyUserCommand> toUpdate = localUsers.stream()
List<UpdateQyUserCommand> toUpdate = qyUserList.stream()
.filter(localUser -> wxUserMap.containsKey(localUser.getUserid()))
.filter(localUser -> {
UserListResponse.UserInfo wxUser = wxUserMap.get(localUser.getUserid());
@ -557,12 +553,12 @@ public class QywxScheduleJob {
}
// 删除用户
if (!toRemove.isEmpty()) {
/*if (!toRemove.isEmpty()) {
BulkOperationCommand<Integer> command = new BulkOperationCommand<>(
toRemove.stream().map(QyUserEntity::getId).collect(Collectors.toList())
);
qyUserApplicationService.deleteUser(command);
}
}*/
}
} catch (Exception e) {
log.error("syncUserInfo error", e);

View File

@ -3,6 +3,8 @@ package com.agileboot.api.controller;
import cn.hutool.json.JSONUtil;
import com.agileboot.common.constant.PayApiConstants;
import com.agileboot.common.core.base.BaseController;
import com.agileboot.common.exception.ApiException;
import com.agileboot.common.exception.error.ErrorCode;
import com.agileboot.domain.cabinet.operation.command.AddCabinetCellOperationCommand;
import com.agileboot.domain.shop.order.dto.CreateOrderResult;
import com.agileboot.domain.shop.order.dto.GetOrdersByOpenIdDTO;
@ -10,7 +12,11 @@ import com.agileboot.domain.shop.order.model.OrderGoodsModelFactory;
import com.agileboot.domain.shop.order.model.OrderModel;
import com.agileboot.domain.shop.payment.PaymentApplicationService;
import com.agileboot.domain.shop.payment.dto.RefundVO;
import com.agileboot.domain.shop.paymentOperationLog.PaymentOperationLogApplicationService;
import com.agileboot.domain.shop.paymentOperationLog.command.AddPaymentOperationLogCommand;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.agileboot.common.core.dto.ResponseDTO;
@ -33,6 +39,7 @@ public class OrderController extends BaseController {
private final OrderApplicationService orderApplicationService;
private final PaymentApplicationService paymentApplicationService;
private final PaymentOperationLogApplicationService paymentOperationLogApplicationService;
/**
* 提交订单接口
@ -41,8 +48,20 @@ public class OrderController extends BaseController {
*/
@PostMapping("/submit")
public ResponseDTO<CreateOrderResult> submitOrder(@Validated @RequestBody SubmitOrderCommand command) {
CreateOrderResult result = orderApplicationService.createOrder(command);
return ResponseDTO.ok(result);
try {
CreateOrderResult result = orderApplicationService.createOrder(command);
return ResponseDTO.ok(result);
} catch (Exception e) {
log.error("submitOrder error: ", e);
AddPaymentOperationLogCommand paymentOperationLogCommand = new AddPaymentOperationLogCommand();
paymentOperationLogCommand.setParams(JSONUtil.toJsonStr(command));
paymentOperationLogCommand.setOperationType("submitOrder");
paymentOperationLogCommand.setStatus(2);
paymentOperationLogCommand.setRemark(ExceptionUtils.getStackTrace(e));
paymentOperationLogCommand.initBaseEntity();
paymentOperationLogApplicationService.addPaymentOperationLog(paymentOperationLogCommand);
return ResponseDTO.fail(new ApiException(ErrorCode.Internal.INTERNAL_ERROR, e));
}
}
/**

View File

@ -28,6 +28,8 @@ import java.nio.charset.StandardCharsets;
import java.util.*;
import javax.servlet.http.HttpServletRequest;
import com.agileboot.domain.shop.paymentOperationLog.PaymentOperationLogApplicationService;
import com.agileboot.domain.shop.paymentOperationLog.command.AddPaymentOperationLogCommand;
import com.agileboot.domain.system.menu.MenuApplicationService;
import com.agileboot.domain.system.menu.dto.RouterDTO;
import com.agileboot.domain.system.user.db.SysUserEntity;
@ -63,6 +65,7 @@ public class PaymentController {
private final SysUserQyUserApplicationService sysUserQyUserApplicationService;
private final MenuApplicationService menuApplicationService;
private final PaymentApplicationService paymentApplicationService;
private final PaymentOperationLogApplicationService paymentOperationLogApplicationService;
// 新增回调接口
/**
@ -78,6 +81,13 @@ public class PaymentController {
@PostMapping("/callback")
public String paymentCallback(HttpServletRequest request, @RequestBody String requestBody) {
log.info("支付回调requestBody{}", requestBody);
// 记录支付操作日志
AddPaymentOperationLogCommand paymentOperationLogCommand = new AddPaymentOperationLogCommand();
paymentOperationLogCommand.setOperationType("payCallback");
paymentOperationLogCommand.setStatus(1);
paymentOperationLogCommand.setRemark(requestBody);
paymentOperationLogCommand.initBaseEntity();
paymentOperationLogApplicationService.addPaymentOperationLog(paymentOperationLogCommand);
try {
paymentApplicationService.paymentCallback(requestBody);
return "success";
@ -108,6 +118,13 @@ public class PaymentController {
@PostMapping("/refund/callback")
public String refundCallback(HttpServletRequest request, @RequestBody String requestBody) {
log.info("退款回调requestBody{}", requestBody);
// 记录支付操作日志
AddPaymentOperationLogCommand paymentOperationLogCommand = new AddPaymentOperationLogCommand();
paymentOperationLogCommand.setOperationType("refundCallback");
paymentOperationLogCommand.setStatus(1);
paymentOperationLogCommand.setRemark(requestBody);
paymentOperationLogCommand.initBaseEntity();
paymentOperationLogApplicationService.addPaymentOperationLog(paymentOperationLogCommand);
try {
return paymentApplicationService.refundCallback(requestBody);
} catch (Exception e) {

View File

@ -1,6 +1,7 @@
package com.agileboot.domain.cabinet.cell;
import com.agileboot.common.core.page.PageDTO;
import com.agileboot.domain.cabinet.cell.dto.CabinetCellWithOrderCountDTO;
import com.agileboot.domain.common.command.BulkOperationCommand;
import com.agileboot.domain.cabinet.cell.command.AddCabinetCellCommand;
import com.agileboot.domain.cabinet.cell.command.UpdateCabinetCellCommand;
@ -29,7 +30,8 @@ public class CabinetCellApplicationService {
private final ShopGoodsService shopGoodsService;
public PageDTO<CabinetCellDTO> getCabinetCellList(SearchCabinetCellQuery<CabinetCellEntity> query) {
Page<CabinetCellEntity> page = cabinetCellService.getCellList(query);
// Page<CabinetCellEntity> page = cabinetCellService.getCellList(query);
Page<CabinetCellWithOrderCountDTO> page = cabinetCellService.getCellListWithOrders(query);
List<ShopGoodsEntity> goodsList = shopGoodsService.selectAll();
List<CabinetCellDTO> dtoList = page.getRecords().stream()
.map(cell -> {

View File

@ -1,5 +1,6 @@
package com.agileboot.domain.cabinet.cell.db;
import com.agileboot.domain.cabinet.cell.dto.CabinetCellWithOrderCountDTO;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
@ -51,4 +52,13 @@ public interface CabinetCellMapper extends BaseMapper<CabinetCellEntity> {
"WHERE cell_id = #{cellId}")
void clearGoodsIdAndFreeCell(@Param("cellId") Long cellId);
@Select("SELECT cc.*, COUNT(sog.order_goods_id) AS orderCount " +
"FROM cabinet_cell cc " +
"LEFT JOIN shop_order_goods sog ON cc.cell_id = sog.cell_id AND sog.deleted = 0 " +
"${ew.customSqlSegment} ")
Page<CabinetCellWithOrderCountDTO> getCellListWithOrders(
Page<CabinetCellEntity> page,
@Param(Constants.WRAPPER) Wrapper<CabinetCellEntity> queryWrapper
);
}

View File

@ -1,9 +1,14 @@
package com.agileboot.domain.cabinet.cell.db;
import com.agileboot.common.core.page.AbstractPageQuery;
import com.agileboot.domain.cabinet.cell.dto.CabinetCellWithOrderCountDTO;
import com.agileboot.domain.cabinet.smartCabinet.dto.CabinetDetailDTO;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
@ -23,4 +28,6 @@ public interface CabinetCellService extends IService<CabinetCellEntity> {
List<CabinetCellEntity> selectByGoodsId(Long goodsId);
void clearGoodsIdAndFreeCell(Long cellId);
Page<CabinetCellWithOrderCountDTO> getCellListWithOrders(AbstractPageQuery<CabinetCellEntity> query);
}

View File

@ -1,6 +1,7 @@
package com.agileboot.domain.cabinet.cell.db;
import com.agileboot.common.core.page.AbstractPageQuery;
import com.agileboot.domain.cabinet.cell.dto.CabinetCellWithOrderCountDTO;
import com.agileboot.domain.cabinet.smartCabinet.dto.CabinetDetailDTO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@ -40,4 +41,9 @@ public class CabinetCellServiceImpl extends ServiceImpl<CabinetCellMapper, Cabin
public void clearGoodsIdAndFreeCell(Long cellId) {
baseMapper.clearGoodsIdAndFreeCell(cellId);
}
@Override
public Page<CabinetCellWithOrderCountDTO> getCellListWithOrders(AbstractPageQuery<CabinetCellEntity> query) {
return baseMapper.getCellListWithOrders(query.toPage(), query.toQueryWrapper());
}
}

View File

@ -25,6 +25,12 @@ public class CabinetCellDTO {
}
}
public CabinetCellDTO(CabinetCellWithOrderCountDTO entity) {
if (entity != null) {
BeanUtil.copyProperties(entity, this);
}
}
@ExcelColumn(name = "格口ID")
private Long cellId;
@ -40,6 +46,9 @@ public class CabinetCellDTO {
@ExcelColumn(name = "库存数量")
private Integer stock;
@ExcelColumn(name = "订单数量")
private Integer orderCount;
@ExcelColumn(name = "格口类型")
private Integer cellType;

View File

@ -0,0 +1,13 @@
package com.agileboot.domain.cabinet.cell.dto;
import com.agileboot.domain.cabinet.cell.db.CabinetCellEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = true)
public class CabinetCellWithOrderCountDTO extends CabinetCellEntity {
@ApiModelProperty("历史订单数量")
private Integer orderCount;
}

View File

@ -0,0 +1,40 @@
package com.agileboot.domain.cabinet.cell.query;
import com.agileboot.common.core.page.AbstractPageQuery;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
@EqualsAndHashCode(callSuper = true)
@Data
public class SearchCabinetCellWithOrdersQuery<T> extends AbstractPageQuery<T> {
private Long cellId;
private Long cabinetId;
private Integer cellNo;
private Integer cellType;
private Integer usageStatus;
private Integer availableStatus;
private Date startTime;
private Date endTime;
@Override
public QueryWrapper<T> addQueryCondition() {
QueryWrapper<T> queryWrapper = new QueryWrapper<>();
queryWrapper
.eq(cellId != null, "cc.cell_id", cellId)
.eq(cabinetId != null, "cc.cabinet_id", cabinetId)
.eq(cellNo != null, "cc.cell_no", cellNo)
.eq(cellType != null, "cc.cell_type", cellType)
.eq(usageStatus != null, "cc.usage_status", usageStatus)
.eq(availableStatus != null, "cc.available_status", availableStatus)
.eq("cc.deleted", false)
.between(startTime != null && endTime != null, "cc.create_time", startTime, endTime);
this.timeRangeColumn = "create_time";
return queryWrapper;
}
}

View File

@ -1,5 +1,6 @@
package com.agileboot.domain.shop.approval;
import cn.hutool.json.JSONUtil;
import com.agileboot.common.constant.PayApiConstants;
import com.agileboot.common.constant.WeixinConstants;
import com.agileboot.common.core.page.PageDTO;
@ -32,6 +33,8 @@ import com.agileboot.domain.shop.order.model.OrderModel;
import com.agileboot.domain.shop.order.model.OrderModelFactory;
import com.agileboot.domain.shop.payment.PaymentApplicationService;
import com.agileboot.domain.shop.payment.dto.RefundVO;
import com.agileboot.domain.shop.paymentOperationLog.PaymentOperationLogApplicationService;
import com.agileboot.domain.shop.paymentOperationLog.command.AddPaymentOperationLogCommand;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.math.BigDecimal;
@ -45,6 +48,7 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.springframework.stereotype.Service;
/**
@ -66,6 +70,7 @@ public class ReturnApprovalApplicationService {
private final QyUserService qyUserService;
private final CabinetCellModelFactory cabinetCellModelFactory;
private final QyUserService userService;
private final PaymentOperationLogApplicationService paymentOperationLogApplicationService;
/**
* 获取退货审批列表
@ -150,7 +155,22 @@ public class ReturnApprovalApplicationService {
PayApiConstants.biz_id, PayApiConstants.appkey,
orderModel.getBizOrderId(), orderModel.getUcid(),
"退还", returnAmount.intValue());
AddPaymentOperationLogCommand paymentOperationLogCommand = new AddPaymentOperationLogCommand();
paymentOperationLogCommand.setParams(JSONUtil.toJsonStr(command));
paymentOperationLogCommand.setOperationType("refund");
paymentOperationLogCommand.setStatus(1);
paymentOperationLogCommand.setRemark(JSONUtil.toJsonStr(refundVO));
paymentOperationLogCommand.initBaseEntity();
paymentOperationLogApplicationService.addPaymentOperationLog(paymentOperationLogCommand);
} catch (Exception e) {
AddPaymentOperationLogCommand paymentOperationLogCommand = new AddPaymentOperationLogCommand();
paymentOperationLogCommand.setParams(JSONUtil.toJsonStr(command));
paymentOperationLogCommand.setOperationType("refund");
paymentOperationLogCommand.setStatus(2);
paymentOperationLogCommand.setRemark(ExceptionUtils.getStackTrace(e));
paymentOperationLogCommand.initBaseEntity();
paymentOperationLogApplicationService.addPaymentOperationLog(paymentOperationLogCommand);
throw new RuntimeException("退款失败", e);
}
log.info("退款结果:{}", refundVO);

View File

@ -65,4 +65,8 @@ public class GoodsApplicationService {
public List<SearchGoodsWithCabinetDO> getGoodsWithCabinetList() {
return shopGoodsService.getGoodsWithCabinetList();
}
public ShopGoodsDTO getGoodsInfo(Long goodsId) {
return new ShopGoodsDTO(shopGoodsService.getGoodsInfo(goodsId));
}
}

View File

@ -71,4 +71,14 @@ public interface ShopGoodsMapper extends BaseMapper<ShopGoodsEntity> {
"LEFT JOIN smart_cabinet sc ON cc.cabinet_id = sc.cabinet_id " +
"WHERE g.deleted = 0 AND sc.deleted = 0 AND cc.deleted = 0 AND cc.goods_id IS NOT NULL ")
List<SearchGoodsWithCabinetDO> getGoodsWithCabinetList();
@Select("SELECT g.goods_id, g.goods_name, g.category_id, g.price, " +
"g.stock, g.status, g.auto_approval, g.cover_img, SUM(cc.stock) AS total_stock, " +
"GROUP_CONCAT(DISTINCT cc.cell_no) AS cell_no_str, " +
"GROUP_CONCAT(DISTINCT sc.cabinet_name) AS cabinet_name " +
"FROM shop_goods g " +
"LEFT JOIN cabinet_cell cc ON g.goods_id = cc.goods_id AND cc.deleted = 0 " +
"LEFT JOIN smart_cabinet sc ON cc.cabinet_id = sc.cabinet_id AND sc.deleted = 0 " +
"WHERE g.goods_id = #{goodsId} ")
SearchGoodsDO getGoodsInfo(@Param("goodsId") Long goodsId);
}

View File

@ -3,6 +3,7 @@ package com.agileboot.domain.shop.goods.db;
import com.agileboot.common.core.page.AbstractPageQuery;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
@ -19,4 +20,6 @@ public interface ShopGoodsService extends IService<ShopGoodsEntity> {
List<ShopGoodsEntity> selectAll();
List<SearchGoodsWithCabinetDO> getGoodsWithCabinetList();
SearchGoodsDO getGoodsInfo(Long goodsId);
}

View File

@ -34,4 +34,9 @@ public class ShopGoodsServiceImpl extends ServiceImpl<ShopGoodsMapper, ShopGoods
public List<SearchGoodsWithCabinetDO> getGoodsWithCabinetList() {
return baseMapper.getGoodsWithCabinetList();
}
@Override
public SearchGoodsDO getGoodsInfo(Long goodsId) {
return baseMapper.getGoodsInfo(goodsId);
}
}

View File

@ -25,6 +25,7 @@ import com.agileboot.domain.shop.order.db.ShopOrderEntity;
import com.agileboot.domain.shop.order.db.ShopOrderService;
import com.agileboot.domain.shop.order.db.ShopOrderGoodsEntity;
import com.agileboot.domain.shop.order.db.ShopOrderGoodsService;
import com.agileboot.domain.shop.order.db.dto.OrderWithGoodsDTO;
import com.agileboot.domain.shop.order.dto.CreateOrderResult;
import com.agileboot.domain.shop.order.dto.GetOrdersByOpenIdDTO;
import com.agileboot.domain.shop.order.dto.ShopOrderDTO;
@ -36,6 +37,8 @@ import com.agileboot.domain.shop.order.query.SearchShopOrderQuery;
import com.agileboot.domain.shop.payment.PaymentApplicationService;
import com.agileboot.domain.shop.payment.dto.WxJsApiPreCreateRequest;
import com.agileboot.domain.shop.payment.dto.WxJsApiPreCreateResponse;
import com.agileboot.domain.shop.paymentOperationLog.PaymentOperationLogApplicationService;
import com.agileboot.domain.shop.paymentOperationLog.command.AddPaymentOperationLogCommand;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import java.math.BigDecimal;
import java.math.RoundingMode;
@ -48,6 +51,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.checkerframework.checker.units.qual.s;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -69,9 +73,10 @@ public class OrderApplicationService {
private final QyUserService userService;
private final QyUserModelFactory qyUserModelFactory;
private final CabinetCellOperationModelFactory cabinetCellOperationModelFactory;
private final PaymentOperationLogApplicationService paymentOperationLogApplicationService;
public PageDTO<ShopOrderEntity> getOrderList(SearchShopOrderQuery<ShopOrderEntity> query) {
Page<ShopOrderEntity> page = orderService.page(query.toPage(), query.toQueryWrapper());
public PageDTO<OrderWithGoodsDTO> getOrderList(SearchShopOrderQuery<OrderWithGoodsDTO> query) {
Page<OrderWithGoodsDTO> page = orderService.getOrderList(query);
return new PageDTO<>(page.getRecords(), page.getTotal());
}
@ -164,6 +169,14 @@ public class OrderApplicationService {
// 新增支付接口调用
WxJsApiPreCreateRequest paymentRequest = buildPaymentRequest(orderModel);
WxJsApiPreCreateResponse paymentResponse = paymentApplicationService.callJsApiPreCreate(paymentRequest);
// 记录支付操作日志
AddPaymentOperationLogCommand paymentOperationLogCommand = new AddPaymentOperationLogCommand();
paymentOperationLogCommand.setParams(JSONUtil.toJsonStr(command));
paymentOperationLogCommand.setOperationType("callJsApiPreCreate");
paymentOperationLogCommand.setStatus(1);
paymentOperationLogCommand.setRemark(JSONUtil.toJsonStr(paymentResponse));
paymentOperationLogCommand.initBaseEntity();
paymentOperationLogApplicationService.addPaymentOperationLog(paymentOperationLogCommand);
return new CreateOrderResult(orderModel.getOrderId(), orderModel.getTotalAmount(), paymentResponse, BigDecimal.valueOf(0));
} else if (Objects.equals(command.getPaymentType(), "balance")) {

View File

@ -1,6 +1,12 @@
package com.agileboot.domain.shop.order.db;
import com.agileboot.domain.shop.order.db.dto.OrderWithGoodsDTO;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
/**
* <p>
@ -12,4 +18,14 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
*/
public interface ShopOrderMapper extends BaseMapper<ShopOrderEntity> {
@Select("SELECT o.*, " +
"GROUP_CONCAT(DISTINCT og.goods_name) AS goodsNames, " +
"GROUP_CONCAT(DISTINCT og.cover_img) AS coverImgs " +
"FROM shop_order o " +
"LEFT JOIN shop_order_goods og ON o.order_id = og.order_id AND og.deleted = 0 " +
"${ew.customSqlSegment}")
Page<OrderWithGoodsDTO> getOrderList(
Page<OrderWithGoodsDTO> page,
@Param(Constants.WRAPPER) Wrapper<OrderWithGoodsDTO> queryWrapper
);
}

View File

@ -1,5 +1,9 @@
package com.agileboot.domain.shop.order.db;
import com.agileboot.domain.shop.order.db.dto.OrderWithGoodsDTO;
import com.agileboot.domain.shop.order.query.SearchShopOrderQuery;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
/**
@ -11,4 +15,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
* @since 2025-03-10
*/
public interface ShopOrderService extends IService<ShopOrderEntity> {
Page<OrderWithGoodsDTO> getOrderList(SearchShopOrderQuery<OrderWithGoodsDTO> query);
}

View File

@ -1,7 +1,11 @@
package com.agileboot.domain.shop.order.db;
import cn.hutool.core.date.DateUtil;
import com.agileboot.domain.shop.order.db.dto.OrderWithGoodsDTO;
import com.agileboot.domain.shop.order.model.OrderModel;
import com.agileboot.domain.shop.order.query.SearchShopOrderQuery;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
@ -15,4 +19,8 @@ import org.springframework.stereotype.Service;
*/
@Service
public class ShopOrderServiceImpl extends ServiceImpl<ShopOrderMapper, ShopOrderEntity> implements ShopOrderService {
@Override
public Page<OrderWithGoodsDTO> getOrderList(SearchShopOrderQuery<OrderWithGoodsDTO> query) {
return baseMapper.getOrderList(query.toPage(), query.toQueryWrapper());
}
}

View File

@ -0,0 +1,12 @@
package com.agileboot.domain.shop.order.db.dto;
import com.agileboot.domain.shop.order.db.ShopOrderEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = true)
public class OrderWithGoodsDTO extends ShopOrderEntity {
private String goodsNames;
private String coverImgs;
}

View File

@ -12,7 +12,8 @@ import lombok.EqualsAndHashCode;
@Data
public class SearchShopOrderQuery<T> extends AbstractPageQuery<T> {
private String orderNumber;
private Long orderId;
private Long cellId;
private Integer status;
private Integer payStatus;
private Date startTime;
@ -25,16 +26,18 @@ public class SearchShopOrderQuery<T> extends AbstractPageQuery<T> {
QueryWrapper<T> queryWrapper = new QueryWrapper<>();
queryWrapper
.like(StrUtil.isNotEmpty(orderNumber), "order_number", orderNumber)
.eq(status != null, "status", status)
.eq(payStatus != null, "pay_status", payStatus)
.eq(StrUtil.isNotEmpty(paymentMethod), "payment_method", paymentMethod)
.between(startTime != null && endTime != null, "create_time", startTime, endTime)
.between(payTime != null, "pay_time",
.eq(orderId != null, "o.order_id", orderId)
.eq(cellId != null, "og.cell_id", cellId)
.eq(status != null, "o.status", status)
.eq(payStatus != null, "o.pay_status", payStatus)
.eq(StrUtil.isNotEmpty(paymentMethod), "o.payment_method", paymentMethod)
.between(startTime != null && endTime != null, "o.create_time", startTime, endTime)
.between(payTime != null, "o.pay_time",
payTime == null ? null : DateUtil.beginOfDay(payTime).toJdkDate(),
payTime == null ? null : DateUtil.endOfDay(payTime).toJdkDate())
.eq("deleted", 0)
.orderByDesc("create_time");
.eq("o.deleted", 0)
.groupBy("o.order_id")
.orderByDesc("o.create_time");
return queryWrapper;
}

View File

@ -39,10 +39,17 @@ public class PaymentOperationLogEntity extends BaseEntity<PaymentOperationLogEnt
@TableField("`status`")
private Integer status;
@ApiModelProperty("操作类型")
@TableField("operation_type")
private String operationType;
@ApiModelProperty("操作备注")
@TableField("remark")
private String remark;
@ApiModelProperty("操作参数")
@TableField("params")
private String params;
@Override
public Serializable pkVal() {

View File

@ -29,9 +29,15 @@ public class PaymentOperationLogDTO {
@ExcelColumn(name = "操作状态")
private String statusStr;
@ExcelColumn(name = "操作类型")
private String operationType;
@ExcelColumn(name = "操作备注")
private String remark;
@ExcelColumn(name = "操作参数")
private String params;
@ExcelColumn(name = "操作人")
private String operatorName;
}

View File

@ -16,6 +16,7 @@ public class SearchUserQuery<T> extends AbstractPageQuery<T> {
protected Long userId;
protected String username;
protected String nickname;
protected Integer status;
protected String phoneNumber;
protected Long deptId;
@ -26,6 +27,7 @@ public class SearchUserQuery<T> extends AbstractPageQuery<T> {
queryWrapper.like(StrUtil.isNotEmpty(username), "username", username)
.like(StrUtil.isNotEmpty(phoneNumber), "u.phone_number", phoneNumber)
.like(StrUtil.isNotEmpty(nickname), "u.nickname", nickname)
.eq(userId != null, "u.user_id", userId)
.eq(status != null, "u.status", status)
.eq("u.deleted", 0)

View File

@ -12,4 +12,12 @@ CREATE TABLE `payment_operation_log` (
`deleted` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '删除标志0存在 1删除',
PRIMARY KEY (`log_id`),
KEY `idx_create_time` (`create_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='支付操作日志表';
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='支付操作日志表';
ALTER TABLE `payment_operation_log`
ADD COLUMN `operation_type` VARCHAR(50) NULL DEFAULT '' COMMENT '操作类型'
AFTER `status`;
ALTER TABLE `payment_operation_log`
ADD COLUMN `params` TEXT DEFAULT NULL COMMENT '操作参数'
AFTER `remark`;