From fa128b619b5300b8341a21ecd58966cfe166f69d Mon Sep 17 00:00:00 2001 From: haoxr <1490493387@qq.com> Date: Tue, 27 Dec 2022 23:55:02 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=AE=A1=E7=90=86=E7=AB=AF=E8=AE=A2?= =?UTF-8?q?=E5=8D=95service=E6=8B=86=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../oms/service/admin/OmsOrderService.java | 36 ++++++++ .../admin/impl/OmsOrderServiceImpl.java | 83 +++++++++++++++++++ 2 files changed, 119 insertions(+) create mode 100644 mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/admin/OmsOrderService.java create mode 100644 mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/admin/impl/OmsOrderServiceImpl.java diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/admin/OmsOrderService.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/admin/OmsOrderService.java new file mode 100644 index 000000000..a63eba794 --- /dev/null +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/admin/OmsOrderService.java @@ -0,0 +1,36 @@ +package com.youlai.mall.oms.service.admin; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.IService; +import com.youlai.mall.oms.dto.SeataOrderDTO; +import com.youlai.mall.oms.pojo.entity.OmsOrder; +import com.youlai.mall.oms.pojo.query.OrderPageQuery; + +/** + * 「管理端」订单业务接口 + * + * @author haoxr + * @date 2020/12/30 + */ +public interface OmsOrderService extends IService { + /** + * 订单分页列表 + * + * @param queryParams + * @return + */ + IPage listOrderPages(OrderPageQuery queryParams); + + + /** + * 「实验室」订单支付 + *

+ * 非商城业务 + * + * @param orderDTO + * @return + */ + Boolean payOrder(Long orderId, SeataOrderDTO orderDTO); + +} + diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/admin/impl/OmsOrderServiceImpl.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/admin/impl/OmsOrderServiceImpl.java new file mode 100644 index 000000000..d6c2e1277 --- /dev/null +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/admin/impl/OmsOrderServiceImpl.java @@ -0,0 +1,83 @@ +package com.youlai.mall.oms.service.admin.impl; + +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.youlai.common.redis.BusinessSnGenerator; +import com.youlai.mall.oms.common.enums.OrderStatusEnum; +import com.youlai.mall.oms.dto.SeataOrderDTO; +import com.youlai.mall.oms.mapper.OrderMapper; +import com.youlai.mall.oms.pojo.entity.OmsOrder; +import com.youlai.mall.oms.pojo.query.OrderPageQuery; +import com.youlai.mall.oms.service.admin.OmsOrderService; +import com.youlai.mall.ums.api.MemberFeignClient; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 「管理端」订单业务实现类 + * + * @author haoxr + * @date 2022/2/12 + */ +@Service +@RequiredArgsConstructor +@Slf4j +public class OmsOrderServiceImpl extends ServiceImpl implements OmsOrderService { + + private final MemberFeignClient memberFeignClient; + private final BusinessSnGenerator businessSnGenerator; + + /** + * 订单分页列表 + * + * @param queryParams + * @return + */ + @Override + public IPage listOrderPages(OrderPageQuery queryParams) { + Page page = new Page<>(queryParams.getPageNum(), queryParams.getPageSize()); + List list = this.baseMapper.listOrderPages(page, queryParams); + page.setRecords(list); + return page; + } + + + /** + * 「实验室」订单支付 + * + * @param orderDTO + * @return + */ + @Override + public Boolean payOrder(Long orderId, SeataOrderDTO orderDTO) { + + Long memberId = orderDTO.getMemberId(); + Long amount = orderDTO.getAmount(); + + // 扣减账户余额 + memberFeignClient.deductBalance(memberId, amount); + + // 是否开启异常 + Boolean openEx = orderDTO.getOpenEx(); + if (openEx) { + int i = 1 / 0; + } + + // 修改订单【已支付】 + String orderSn = businessSnGenerator.generateSerialNo("ORDER"); + + boolean result = this.update(new LambdaUpdateWrapper() + .eq(OmsOrder::getId, orderId) + .set(OmsOrder::getOrderSn, orderSn) + .set(OmsOrder::getStatus, OrderStatusEnum.PAID.getValue()) + ); + + return result; + } + +}