TASK:买家端/卖家端接入支付服务
This commit is contained in:
5
pom.xml
5
pom.xml
@@ -176,6 +176,11 @@
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-aop</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.aida.seller.module.order.dto.CreateOrderDTO;
|
||||
import com.aida.seller.module.order.dto.OrderListDTO;
|
||||
import com.aida.seller.module.order.dto.BuyerOrdersDTO;
|
||||
import com.aida.seller.module.order.dto.UpdateOrderStatusDTO;
|
||||
import com.aida.seller.module.order.dto.UpdatePaymentIdDTO;
|
||||
import com.aida.seller.module.order.service.OrderService;
|
||||
import com.aida.seller.module.order.vo.AssetsItemVO;
|
||||
import com.aida.seller.module.order.vo.BuyerOrderVO;
|
||||
@@ -96,4 +97,13 @@ public class OrderController {
|
||||
public Response<PageResponse<AssetsItemVO>> getAssetsPage(@RequestBody AssetsDTO dto) {
|
||||
return Response.success(PageResponse.success(orderService.getAssetsPage(dto)));
|
||||
}
|
||||
|
||||
@InternalOnly
|
||||
@PutMapping("/payment-id/batch")
|
||||
@Operation(summary = "批量回填PaymentId(仅内部服务调用)")
|
||||
public Response<Void> updatePaymentIdByIds(@RequestBody UpdatePaymentIdDTO dto) {
|
||||
orderService.updatePaymentIdByIds(dto.getOrderIds(), dto.getPaymentId());
|
||||
return Response.success();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,22 +2,29 @@ package com.aida.seller.module.order.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 批量修改订单状态请求参数
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@Schema(description = "批量修改订单状态请求参数")
|
||||
public class UpdateOrderStatusDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "交易流水号")
|
||||
private Long paymentId;
|
||||
|
||||
@Schema(description = "订单ID列表")
|
||||
private List<Long> orderIds;
|
||||
|
||||
@Schema(description = "目标状态:0-未支付,1-已支付,2-已取消")
|
||||
private Integer status;
|
||||
|
||||
public UpdateOrderStatusDTO(Integer status, Long paymentId) {
|
||||
this.status = status;
|
||||
this.paymentId = paymentId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.aida.seller.module.order.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 批量回填PaymentId请求参数
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "批量回填PaymentId请求参数")
|
||||
public class UpdatePaymentIdDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "订单ID列表")
|
||||
private List<Long> orderIds;
|
||||
|
||||
@Schema(description = "支付单ID")
|
||||
private Long paymentId;
|
||||
}
|
||||
@@ -57,4 +57,7 @@ public class OrderInfoEntity implements Serializable {
|
||||
/** 是否删除:0-否,1-是 */
|
||||
@TableLogic
|
||||
private Integer deleted;
|
||||
|
||||
/** 交易流水号 */
|
||||
private String paymentId;
|
||||
}
|
||||
|
||||
@@ -75,4 +75,11 @@ public interface OrderService {
|
||||
* @return 已购买的商品ID列表
|
||||
*/
|
||||
List<Long> getPurchasedListingIds(List<Long> listingIds, Long buyerId);
|
||||
|
||||
/**
|
||||
* 根据订单号回填交易流水号
|
||||
* @param orderIds 订单编号列表
|
||||
* @param paymentId 交易流水号(仅供内部使用,不对外)
|
||||
*/
|
||||
void updatePaymentIdByIds(List<Long> orderIds, Long paymentId);
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
@@ -43,6 +44,7 @@ import java.util.stream.Collectors;
|
||||
/**
|
||||
* 订单服务实现
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class OrderServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfoEntity> implements OrderService {
|
||||
@@ -296,19 +298,31 @@ public class OrderServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfoEnti
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateOrderStatus(UpdateOrderStatusDTO dto) {
|
||||
if (dto == null || dto.getOrderIds() == null || dto.getOrderIds().isEmpty()) {
|
||||
throw new BusinessException("订单ID列表不能为空");
|
||||
if (dto == null) {
|
||||
throw new BusinessException("订单信息为空");
|
||||
}
|
||||
if (dto.getStatus() == null) {
|
||||
throw new BusinessException("订单状态不能为空");
|
||||
}
|
||||
if (dto.getPaymentId() == null && (dto.getOrderIds() == null || dto.getOrderIds().isEmpty())) {
|
||||
throw new BusinessException("订单ID列表不能为空");
|
||||
}
|
||||
|
||||
boolean updated;
|
||||
LambdaUpdateWrapper<OrderInfoEntity> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.in(OrderInfoEntity::getId, dto.getOrderIds())
|
||||
.set(OrderInfoEntity::getStatus, dto.getStatus());
|
||||
boolean updated = this.update(updateWrapper);
|
||||
if (dto.getPaymentId() != null) {
|
||||
updateWrapper.eq(OrderInfoEntity::getPaymentId, dto.getPaymentId())
|
||||
.set(OrderInfoEntity::getStatus, dto.getStatus());
|
||||
} else {
|
||||
updateWrapper.in(OrderInfoEntity::getId, dto.getOrderIds())
|
||||
.set(OrderInfoEntity::getStatus, dto.getStatus());
|
||||
}
|
||||
updated = this.update(updateWrapper);
|
||||
|
||||
if (!updated) {
|
||||
throw new BusinessException("订单不存在或无权修改");
|
||||
} else {
|
||||
log.info("[Order] PaymentId:{} / OrderId:{}, 更新订单状态", dto.getPaymentId(), dto.getOrderIds());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -346,4 +360,15 @@ public class OrderServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfoEnti
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePaymentIdByIds(List<Long> orderIds, Long paymentId) {
|
||||
if (CollectionUtils.isEmpty(orderIds)) {
|
||||
throw new BusinessException("订单ID列表不能为空");
|
||||
}
|
||||
LambdaUpdateWrapper<OrderInfoEntity> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.in(OrderInfoEntity::getId, orderIds)
|
||||
.set(OrderInfoEntity::getPaymentId, paymentId);
|
||||
this.update(updateWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,9 @@ CREATE TABLE seller_listing (
|
||||
INDEX idx_deleted (deleted)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='商品表';
|
||||
|
||||
ALTER TABLE seller_listing
|
||||
ADD COLUMN sales_volume INT DEFAULT 0 COMMENT '销量';
|
||||
|
||||
-- 商品图片表
|
||||
CREATE TABLE seller_listing_image (
|
||||
id BIGINT PRIMARY KEY COMMENT '图片ID',
|
||||
@@ -93,3 +96,7 @@ CREATE TABLE seller_order_item (
|
||||
INDEX idx_listing_id (listing_id),
|
||||
INDEX idx_deleted (deleted)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='订单商品明细表';
|
||||
|
||||
-- 新增 payment_id 字段
|
||||
ALTER TABLE seller_orders
|
||||
ADD COLUMN payment_id VARCHAR(64) DEFAULT NULL COMMENT '交易流水号(关联支付表)';
|
||||
Reference in New Issue
Block a user