Procházet zdrojové kódy

day15
订单延迟关单;对接微信支付

it_lv před 1 týdnem
rodič
revize
5f5802e1df
24 změnil soubory, kde provedl 699 přidání a 25 odebrání
  1. 1 1
      common/rabbit-util/src/main/java/com/atguigu/tingshu/common/rabbit/service/RabbitService.java
  2. 1 1
      common/service-util/src/main/java/com/atguigu/tingshu/common/constant/SystemConstant.java
  3. 26 5
      model/src/main/java/com/atguigu/tingshu/model/order/OrderInfo.java
  4. 12 0
      service-client/service-account-client/src/main/java/com/atguigu/tingshu/account/AccountFeignClient.java
  5. 7 0
      service-client/service-account-client/src/main/java/com/atguigu/tingshu/account/impl/AccountDegradeFeignClient.java
  6. 13 1
      service-client/service-order-client/src/main/java/com/atguigu/tingshu/order/client/OrderFeignClient.java
  7. 6 0
      service-client/service-order-client/src/main/java/com/atguigu/tingshu/order/client/impl/OrderDegradeFeignClient.java
  8. 19 0
      service/service-account/src/main/java/com/atguigu/tingshu/account/api/RechargeInfoApiController.java
  9. 6 0
      service/service-account/src/main/java/com/atguigu/tingshu/account/service/RechargeInfoService.java
  10. 12 0
      service/service-account/src/main/java/com/atguigu/tingshu/account/service/impl/RechargeInfoServiceImpl.java
  11. 29 0
      service/service-order/src/main/java/com/atguigu/tingshu/order/admin/OrderInfoController.java
  12. 35 4
      service/service-order/src/main/java/com/atguigu/tingshu/order/api/OrderInfoApiController.java
  13. 35 0
      service/service-order/src/main/java/com/atguigu/tingshu/order/config/CanelOrderMqConfig.java
  14. 9 0
      service/service-order/src/main/java/com/atguigu/tingshu/order/mapper/OrderInfoMapper.java
  15. 41 0
      service/service-order/src/main/java/com/atguigu/tingshu/order/receiver/OrderReceiver.java
  16. 22 0
      service/service-order/src/main/java/com/atguigu/tingshu/order/service/OrderInfoService.java
  17. 115 7
      service/service-order/src/main/java/com/atguigu/tingshu/order/service/impl/OrderInfoServiceImpl.java
  18. 55 0
      service/service-order/src/main/resources/mapper/OrderInfoMapper.xml
  19. 42 2
      service/service-payment/src/main/java/com/atguigu/tingshu/payment/api/WxPayApiController.java
  20. 4 2
      service/service-payment/src/main/java/com/atguigu/tingshu/payment/config/WxPayV3Config.java
  21. 10 0
      service/service-payment/src/main/java/com/atguigu/tingshu/payment/service/PaymentInfoService.java
  22. 16 0
      service/service-payment/src/main/java/com/atguigu/tingshu/payment/service/WxPayService.java
  23. 80 0
      service/service-payment/src/main/java/com/atguigu/tingshu/payment/service/impl/PaymentInfoServiceImpl.java
  24. 103 2
      service/service-payment/src/main/java/com/atguigu/tingshu/payment/service/impl/WxPayServiceImpl.java

+ 1 - 1
common/rabbit-util/src/main/java/com/atguigu/tingshu/common/rabbit/service/RabbitService.java

@@ -50,7 +50,7 @@ public class RabbitService {
      * @param message    消息数据
      * @param delayTime  延迟时间,单位为:秒
      */
-    public boolean sendDealyMessage(String exchange, String routingKey, Object message, int delayTime) {
+    public boolean sendDelayMessage(String exchange, String routingKey, Object message, int delayTime) {
         //1.创建自定义相关消息对象-包含业务数据本身,交换器名称,路由键,队列类型,延迟时间,重试次数
         GuiguCorrelationData correlationData = new GuiguCorrelationData();
         String uuid = "mq:" + UUID.randomUUID().toString().replaceAll("-", "");

+ 1 - 1
common/service-util/src/main/java/com/atguigu/tingshu/common/constant/SystemConstant.java

@@ -43,7 +43,7 @@ public class SystemConstant {
     public static final String  USER_STATUS_NORMAL="0801";  // 正常
     public static final String  USER_STATUS_LOCK="0802";  // 锁定
 
-    //订单状态 0901-正常 0902-已支付 0903-已取消
+    //订单或充值状态 0901-正常 0902-已支付 0903-已取消
     public static final String  ORDER_STATUS_UNPAID="0901";  // 未支付
     public static final String  ORDER_STATUS_PAID="0902";  // 已支付
     public static final String  ORDER_STATUS_CANCEL="0903";  // 已取消

+ 26 - 5
model/src/main/java/com/atguigu/tingshu/model/order/OrderInfo.java

@@ -61,9 +61,30 @@ public class OrderInfo extends BaseEntity {
 	@TableField(exist = false)
 	private List<OrderDerate> orderDerateList;
 
-	@TableField(exist = false)
-	private String orderStatusName;
-	@TableField(exist = false)
-	private String payWayName;
 
-}
+	/**
+	 * 订单状态名称
+	 * @return
+	 */
+	public String getOrderStatusName() {
+		if("0901".equals(orderStatus)){
+			return "未支付";
+		} else if ("0902".equals(orderStatus)) {
+			return "已支付";
+		} else if ("0903".equals(orderStatus)) {
+			return "已取消";
+		}
+		return null;
+	}
+
+	public String getPayWayName() {
+		if ("1101".equals(payWay)) {
+			return "微信";
+		} else if ("1102".equals(payWay)) {
+			return "支付宝";
+		} else if ("1103".equals(payWay)) {
+			return "余额";
+		}
+		return "";
+	}
+}

+ 12 - 0
service-client/service-account-client/src/main/java/com/atguigu/tingshu/account/AccountFeignClient.java

@@ -2,8 +2,11 @@ package com.atguigu.tingshu.account;
 
 import com.atguigu.tingshu.account.impl.AccountDegradeFeignClient;
 import com.atguigu.tingshu.common.result.Result;
+import com.atguigu.tingshu.model.account.RechargeInfo;
 import com.atguigu.tingshu.vo.account.AccountDeductVo;
 import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 
@@ -24,4 +27,13 @@ public interface AccountFeignClient {
      */
     @PostMapping("/userAccount/checkAndDeduct")
     public Result checkAndDeduct(@RequestBody AccountDeductVo accountDeductVo);
+
+
+    /**
+     * 根据充值订单编号查询充值记录
+     * @param orderNo
+     * @return
+     */
+    @GetMapping("/rechargeInfo/getRechargeInfo/{orderNo}")
+    public Result<RechargeInfo> getRechargeInfo(@PathVariable("orderNo") String orderNo);
 }

+ 7 - 0
service-client/service-account-client/src/main/java/com/atguigu/tingshu/account/impl/AccountDegradeFeignClient.java

@@ -3,6 +3,7 @@ package com.atguigu.tingshu.account.impl;
 
 import com.atguigu.tingshu.account.AccountFeignClient;
 import com.atguigu.tingshu.common.result.Result;
+import com.atguigu.tingshu.model.account.RechargeInfo;
 import com.atguigu.tingshu.vo.account.AccountDeductVo;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Component;
@@ -16,4 +17,10 @@ public class AccountDegradeFeignClient implements AccountFeignClient {
         log.error("[账户服务]提供远程调用方法:{},执行服务降级", "checkAndDeduct");
         return null;
     }
+
+    @Override
+    public Result<RechargeInfo> getRechargeInfo(String orderNo) {
+        log.error("[账户服务]提供远程调用方法:{},执行服务降级", "getRechargeInfo");
+        return null;
+    }
 }

+ 13 - 1
service-client/service-order-client/src/main/java/com/atguigu/tingshu/order/client/OrderFeignClient.java

@@ -1,7 +1,11 @@
 package com.atguigu.tingshu.order.client;
 
+import com.atguigu.tingshu.common.result.Result;
+import com.atguigu.tingshu.model.order.OrderInfo;
 import com.atguigu.tingshu.order.client.impl.OrderDegradeFeignClient;
 import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
 
 /**
  * <p>
@@ -10,8 +14,16 @@ import org.springframework.cloud.openfeign.FeignClient;
  *
  * @author atguigu
  */
-@FeignClient(value = "service-order", fallback = OrderDegradeFeignClient.class)
+@FeignClient(value = "service-order",path = "/api/order", fallback = OrderDegradeFeignClient.class)
 public interface OrderFeignClient {
 
 
+    /**
+     * 根据订单编号查询订单信息
+     * @param orderNo
+     * @return
+     */
+    @GetMapping("/orderInfo/getOrderInfo/{orderNo}")
+    public Result<OrderInfo> getOrderInfo(@PathVariable("orderNo") String orderNo);
+
 }

+ 6 - 0
service-client/service-order-client/src/main/java/com/atguigu/tingshu/order/client/impl/OrderDegradeFeignClient.java

@@ -1,10 +1,16 @@
 package com.atguigu.tingshu.order.client.impl;
 
 
+import com.atguigu.tingshu.common.result.Result;
+import com.atguigu.tingshu.model.order.OrderInfo;
 import com.atguigu.tingshu.order.client.OrderFeignClient;
 import org.springframework.stereotype.Component;
 
 @Component
 public class OrderDegradeFeignClient implements OrderFeignClient {
 
+    @Override
+    public Result<OrderInfo> getOrderInfo(String orderNo) {
+        return null;
+    }
 }

+ 19 - 0
service/service-account/src/main/java/com/atguigu/tingshu/account/api/RechargeInfoApiController.java

@@ -1,8 +1,13 @@
 package com.atguigu.tingshu.account.api;
 
 import com.atguigu.tingshu.account.service.RechargeInfoService;
+import com.atguigu.tingshu.common.result.Result;
+import com.atguigu.tingshu.model.account.RechargeInfo;
+import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
@@ -15,5 +20,19 @@ public class RechargeInfoApiController {
 	@Autowired
 	private RechargeInfoService rechargeInfoService;
 
+
+	/**
+	 * 根据充值订单编号查询充值记录
+	 * @param orderNo
+	 * @return
+	 */
+	@Operation(summary = "根据充值订单编号查询充值记录")
+	@GetMapping("/rechargeInfo/getRechargeInfo/{orderNo}")
+	public Result<RechargeInfo> getRechargeInfo(@PathVariable("orderNo") String orderNo) {
+		RechargeInfo rechargeInfo = rechargeInfoService.getRechargeInfo(orderNo);
+		return Result.ok(rechargeInfo);
+	}
+
+
 }
 

+ 6 - 0
service/service-account/src/main/java/com/atguigu/tingshu/account/service/RechargeInfoService.java

@@ -5,4 +5,10 @@ import com.baomidou.mybatisplus.extension.service.IService;
 
 public interface RechargeInfoService extends IService<RechargeInfo> {
 
+    /**
+     * 根据充值订单编号查询充值记录
+     * @param orderNo
+     * @return
+     */
+    RechargeInfo getRechargeInfo(String orderNo);
 }

+ 12 - 0
service/service-account/src/main/java/com/atguigu/tingshu/account/service/impl/RechargeInfoServiceImpl.java

@@ -3,6 +3,7 @@ package com.atguigu.tingshu.account.service.impl;
 import com.atguigu.tingshu.account.mapper.RechargeInfoMapper;
 import com.atguigu.tingshu.account.service.RechargeInfoService;
 import com.atguigu.tingshu.model.account.RechargeInfo;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -14,4 +15,15 @@ public class RechargeInfoServiceImpl extends ServiceImpl<RechargeInfoMapper, Rec
 	@Autowired
 	private RechargeInfoMapper rechargeInfoMapper;
 
+	/**
+	 * 根据充值订单编号查询充值记录
+	 * @param orderNo
+	 * @return
+	 */
+	@Override
+	public RechargeInfo getRechargeInfo(String orderNo) {
+		LambdaQueryWrapper<RechargeInfo> queryWrapper = new LambdaQueryWrapper<>();
+		queryWrapper.eq(RechargeInfo::getOrderNo, orderNo);
+		return baseMapper.selectOne(queryWrapper);
+	}
 }

+ 29 - 0
service/service-order/src/main/java/com/atguigu/tingshu/order/admin/OrderInfoController.java

@@ -0,0 +1,29 @@
+package com.atguigu.tingshu.order.admin;
+
+import com.atguigu.tingshu.common.result.Result;
+import com.atguigu.tingshu.model.order.OrderInfo;
+import com.atguigu.tingshu.order.service.OrderInfoService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("admin/order")
+/**
+ * @author: atguigu
+ * @create: 2025-03-26 09:19
+ */
+public class OrderInfoController {
+
+    @Autowired
+    private OrderInfoService orderInfoService;
+
+
+    @GetMapping("/orderInfo/{orderNo}")
+    public Result<OrderInfo> getOrderInfo(@PathVariable("orderNo") String orderNo) {
+        OrderInfo orderInfo = orderInfoService.getOrderInfo(orderNo);
+        return Result.ok(orderInfo);
+    }
+}

+ 35 - 4
service/service-order/src/main/java/com/atguigu/tingshu/order/api/OrderInfoApiController.java

@@ -3,17 +3,16 @@ package com.atguigu.tingshu.order.api;
 import com.atguigu.tingshu.common.login.GuiGuLogin;
 import com.atguigu.tingshu.common.result.Result;
 import com.atguigu.tingshu.common.util.AuthContextHolder;
+import com.atguigu.tingshu.model.order.OrderInfo;
 import com.atguigu.tingshu.order.service.OrderInfoService;
 import com.atguigu.tingshu.vo.order.OrderInfoVo;
 import com.atguigu.tingshu.vo.order.TradeVo;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -64,5 +63,37 @@ public class OrderInfoApiController {
 		return Result.ok(map);
 	}
 
+
+	/**
+	 * 根据订单编号查询订单信息
+	 * TODO 场景:如果是提供给用户端需要登录才能访问(订单编号+用户ID);如果是系统内部调用,则不需要登录
+	 * @param orderNo
+	 * @return
+	 */
+	@Operation(summary = "根据订单编号查询订单信息")
+	@GetMapping("/orderInfo/getOrderInfo/{orderNo}")
+	public Result<OrderInfo> getOrderInfo(@PathVariable("orderNo") String orderNo) {
+		OrderInfo orderInfo = orderInfoService.getOrderInfo(orderNo);
+		return Result.ok(orderInfo);
+	}
+
+	/**
+	 * 分页查询当前用户订单列表
+	 * @param page
+	 * @param limit
+	 * @return
+	 */
+	@GuiGuLogin
+	@Operation(summary = "分页查询当前用户订单列表(包含订单明细)")
+	@GetMapping("/orderInfo/findUserPage/{page}/{limit}")
+	public Result<Page<OrderInfo>> findUserOrderPage(@PathVariable Long page, @PathVariable Long limit){
+		//1.获取用户ID
+		Long userId = AuthContextHolder.getUserId();
+		//2.创建分页对象Page,封装当前页,页大小
+		Page<OrderInfo> pageInfo = new Page<>(page, limit);
+		//3.调用业务层分页方法
+		pageInfo = orderInfoService.findUserOrderPage(pageInfo, userId);
+		return Result.ok(pageInfo);
+	}
 }
 

+ 35 - 0
service/service-order/src/main/java/com/atguigu/tingshu/order/config/CanelOrderMqConfig.java

@@ -0,0 +1,35 @@
+package com.atguigu.tingshu.order.config;
+
+import com.atguigu.tingshu.common.rabbit.constant.MqConst;
+import org.springframework.amqp.core.Binding;
+import org.springframework.amqp.core.BindingBuilder;
+import org.springframework.amqp.core.CustomExchange;
+import org.springframework.amqp.core.Queue;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@Configuration
+public class CanelOrderMqConfig {
+
+    @Bean
+    public Queue cancelQueue() {
+        // 第一个参数是创建的queue的名字,第二个参数是是否支持持久化
+        return new Queue(MqConst.QUEUE_CANCEL_ORDER, true);
+    }
+
+    @Bean
+    public CustomExchange cancelExchange() {
+        Map<String, Object> args = new HashMap<String, Object>();
+        args.put("x-delayed-type", "direct");
+        return new CustomExchange(MqConst.EXCHANGE_CANCEL_ORDER, "x-delayed-message", true, false, args);
+    }
+
+    @Bean
+    public Binding bindingCancel() {
+        return BindingBuilder.bind(cancelQueue()).to(cancelExchange()).with(MqConst.ROUTING_CANCEL_ORDER).noargs();
+    }
+
+}

+ 9 - 0
service/service-order/src/main/java/com/atguigu/tingshu/order/mapper/OrderInfoMapper.java

@@ -2,9 +2,18 @@ package com.atguigu.tingshu.order.mapper;
 
 import com.atguigu.tingshu.model.order.OrderInfo;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 
 @Mapper
 public interface OrderInfoMapper extends BaseMapper<OrderInfo> {
 
+    /**
+     * 查询指定用户订单列表
+     * @param pageInfo
+     * @param userId
+     * @return
+     */
+    Page<OrderInfo> findUserOrderPage(Page<OrderInfo> pageInfo, @Param("userId") Long userId);
 }

+ 41 - 0
service/service-order/src/main/java/com/atguigu/tingshu/order/receiver/OrderReceiver.java

@@ -0,0 +1,41 @@
+package com.atguigu.tingshu.order.receiver;
+
+import com.atguigu.tingshu.common.rabbit.constant.MqConst;
+import com.atguigu.tingshu.order.service.OrderInfoService;
+import com.rabbitmq.client.Channel;
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.amqp.core.Message;
+import org.springframework.amqp.rabbit.annotation.RabbitListener;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+
+/**
+ * @author: atguigu
+ * @create: 2025-03-26 10:43
+ */
+@Slf4j
+@Component
+public class OrderReceiver {
+
+    @Autowired
+    private OrderInfoService orderInfoService;
+
+    /**
+     * 监听到延迟关单消息
+     *
+     * @param orderId
+     * @param message
+     * @param channel
+     */
+    @SneakyThrows
+    @RabbitListener(queues = MqConst.QUEUE_CANCEL_ORDER)
+    public void cancelOrder(Long orderId, Message message, Channel channel) {
+        if (orderId != null) {
+            log.info("订单服务接收到取消订单消息,订单ID:{}", orderId);
+            orderInfoService.cancelOrder(orderId);
+        }
+        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
+    }
+}

+ 22 - 0
service/service-order/src/main/java/com/atguigu/tingshu/order/service/OrderInfoService.java

@@ -3,6 +3,7 @@ package com.atguigu.tingshu.order.service;
 import com.atguigu.tingshu.model.order.OrderInfo;
 import com.atguigu.tingshu.vo.order.OrderInfoVo;
 import com.atguigu.tingshu.vo.order.TradeVo;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.IService;
 
 public interface OrderInfoService extends IService<OrderInfo> {
@@ -29,4 +30,25 @@ public interface OrderInfoService extends IService<OrderInfo> {
      * @return
      */
     OrderInfo saveOrderInfo(OrderInfoVo orderInfoVo);
+
+    /**
+     * 根据订单编号查询订单信息(包含订单明细,优惠列表)
+     * @param orderNo
+     * @return
+     */
+    OrderInfo getOrderInfo(String orderNo);
+
+    /**
+     * 分页查询当前用户订单列表
+     * @param pageInfo
+     * @param userId
+     * @return
+     */
+    Page<OrderInfo> findUserOrderPage(Page<OrderInfo> pageInfo, Long userId);
+
+    /**
+     * 根据订单ID检查订单支付状态,如果未支付则更新订单状态为已取消
+     * @param orderId
+     */
+    void cancelOrder(Long orderId);
 }

+ 115 - 7
service/service-order/src/main/java/com/atguigu/tingshu/order/service/impl/OrderInfoServiceImpl.java

@@ -3,10 +3,13 @@ package com.atguigu.tingshu.order.service.impl;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.lang.Assert;
 import com.atguigu.tingshu.account.AccountFeignClient;
 import com.atguigu.tingshu.album.AlbumFeignClient;
 import com.atguigu.tingshu.common.constant.RedisConstant;
 import com.atguigu.tingshu.common.execption.GuiguException;
+import com.atguigu.tingshu.common.rabbit.constant.MqConst;
+import com.atguigu.tingshu.common.rabbit.service.RabbitService;
 import com.atguigu.tingshu.common.result.Result;
 import com.atguigu.tingshu.common.util.AuthContextHolder;
 import com.atguigu.tingshu.model.order.OrderDerate;
@@ -27,11 +30,15 @@ import com.atguigu.tingshu.vo.order.OrderDetailVo;
 import com.atguigu.tingshu.vo.order.OrderInfoVo;
 import com.atguigu.tingshu.vo.order.TradeVo;
 import com.atguigu.tingshu.vo.user.UserPaidRecordVo;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.IdWorker;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import io.seata.spring.annotation.GlobalTransactional;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.cloud.context.config.annotation.RefreshScope;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.data.redis.core.script.DefaultRedisScript;
 import org.springframework.stereotype.Service;
@@ -45,6 +52,7 @@ import static com.atguigu.tingshu.common.constant.SystemConstant.*;
 
 @Slf4j
 @Service
+@RefreshScope //实现Value注解读取实时刷新
 @SuppressWarnings({"all"})
 public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo> implements OrderInfoService {
 
@@ -76,6 +84,17 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
     private TradeOrderStrategyFactory tradeOrderStrategyFactory;
 
 
+    @Autowired
+    private RabbitService rabbitService;
+
+
+    /**
+     * 对购买商品(VIP会员、专辑、声音)封装订单结算页所需要数据
+     *
+     * @param userId  用户ID
+     * @param tradeVo {购买商品类别,商品ID,声音数量}
+     * @return
+     */
     @Override
     public OrderInfoVo trade(Long userId, TradeVo tradeVo) {
         //1.创建订单VO
@@ -87,6 +106,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
         tradeOrderStrategy.handleTrade(tradeVo, orderInfoVo);
         return orderInfoVo;
     }
+
     /**
      * 对购买商品(VIP会员、专辑、声音)封装订单结算页所需要数据
      *
@@ -249,6 +269,9 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
         return orderInfoVo;
     }*/
 
+    @Value("${order.cancel}")
+    private Integer cancelTTl;
+
     /**
      * 提交订单
      *
@@ -327,15 +350,11 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
                     throw new GuiguException(result.getCode(), result.getMessage());
                 }
             }
-
-            //模拟异常
-            //if (orderInfo.getId() % 2 == 0) {
-            //    int i = 1 / 0;
-            //}
         }
         if (ORDER_PAY_WAY_WEIXIN.equals(payWay)) {
             //5. TODO 处理付款方式为:微信支付 采用延迟消息进行延迟关单
-
+            //rabbitService.sendDelayMessage(MqConst.EXCHANGE_CANCEL_ORDER, MqConst.ROUTING_CANCEL_ORDER, orderInfo.getId(), MqConst.CANCEL_ORDER_DELAY_TIME);
+            rabbitService.sendDelayMessage(MqConst.EXCHANGE_CANCEL_ORDER, MqConst.ROUTING_CANCEL_ORDER, orderInfo.getId(), cancelTTl);
         }
 
         return orderInfo.getOrderNo();
@@ -393,7 +412,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
         }
         //3.保存订单优惠明细列表
         List<OrderDerateVo> orderDerateVoList = orderInfoVo.getOrderDerateVoList();
-        if (CollUtil.isNotEmpty(orderDetailVoList)) {
+        if (CollUtil.isNotEmpty(orderDerateVoList)) {
             orderDerateVoList
                     .stream()
                     .forEach(orderDerateVo -> {
@@ -405,4 +424,93 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
         return orderInfo;
     }
 
+    /**
+     * 根据订单编号查询订单信息(包含订单明细,优惠列表)
+     *
+     * @param orderNo
+     * @return
+     */
+    @Override
+    public OrderInfo getOrderInfo(String orderNo) {
+        //1.根据订单编号查询订单信息
+        OrderInfo orderInfo = baseMapper.selectOne(
+                new LambdaQueryWrapper<OrderInfo>()
+                        .eq(OrderInfo::getOrderNo, orderNo)
+        );
+        Assert.notNull(orderInfo, "订单:{}不存在", orderNo);
+        //2.根据订单ID查询订单明细列表
+        List<OrderDetail> orderDetailList = orderDetailMapper.selectList(
+                new LambdaQueryWrapper<OrderDetail>()
+                        .eq(OrderDetail::getOrderId, orderInfo.getId())
+        );
+        if (CollUtil.isNotEmpty(orderDetailList)) {
+            orderInfo.setOrderDetailList(orderDetailList);
+        }
+
+
+        //3.根据订单ID查询订单优惠列表
+        List<OrderDerate> orderDerateList = orderDerateMapper.selectList(
+                new LambdaQueryWrapper<OrderDerate>()
+                        .eq(OrderDerate::getOrderId, orderInfo.getId())
+        );
+        if (CollUtil.isNotEmpty(orderDerateList)) {
+            orderInfo.setOrderDerateList(orderDerateList);
+        }
+        return orderInfo;
+    }
+
+    /**
+     * 查询指定用户订单列表
+     *
+     * @param pageInfo
+     * @param userId
+     * @return
+     */
+    @Override
+    public Page<OrderInfo> findUserOrderPage(Page<OrderInfo> pageInfo, Long userId) {
+        //1.方式1:采用queryWrapper分页查询订单,遍历订单在查询订单明细
+        //2.方式2:采用自定义SQL分页查询订单,同时查询订单明细
+        //pageInfo = baseMapper.findUserOrderPage(pageInfo, userId);
+        //3.方式3:采用queryWrapper分页查询订单,获取订单ID列表根据订单ID列表查询订单详情,业务逻辑中处理订单明细
+        //3.1 分页查询订单
+        LambdaQueryWrapper<OrderInfo> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(OrderInfo::getUserId, userId);
+        queryWrapper.orderByDesc(OrderInfo::getId);
+        pageInfo = this.page(pageInfo, queryWrapper);
+
+        //3.2 获取订单ID列表
+        List<OrderInfo> records = pageInfo.getRecords();
+        if (CollUtil.isNotEmpty(records)) {
+            List<Long> orderIdList = records.stream().map(OrderInfo::getId).collect(Collectors.toList());
+            List<OrderDetail> orderDetailList = orderDetailMapper.selectList(
+                    new LambdaQueryWrapper<OrderDetail>()
+                            .in(OrderDetail::getOrderId, orderIdList)
+            );
+            //3.3 采用Stream对查询到订单明细列表按照订单ID进行分组 Map中Key为订单ID Map中值为订单明细列表
+            Map<Long, List<OrderDetail>> collect = orderDetailList.stream().collect(Collectors.groupingBy(OrderDetail::getOrderId));
+            //4.遍历订单找出订单下包含订单明细
+            records.stream().forEach(orderInfo -> {
+                orderInfo.setOrderDetailList(collect.get(orderInfo.getId()));
+            });
+        }
+        return pageInfo;
+    }
+
+    /**
+     * 根据订单ID检查订单支付状态,如果未支付则更新订单状态为已取消
+     *
+     * @param orderId
+     */
+    @Override
+    public void cancelOrder(Long orderId) {
+        //1.根据订单ID查询订单信息
+        OrderInfo orderInfo = baseMapper.selectById(orderId);
+        //2.判断订单状态:如果未支付则更新订单状态为已取消
+        if (orderInfo != null && ORDER_STATUS_UNPAID.equals(orderInfo.getOrderStatus())) {
+            orderInfo.setOrderStatus(ORDER_STATUS_CANCEL);
+            baseMapper.updateById(orderInfo);
+            //TODO 远程调用支付服务,修改本地交易记录状态:已关闭
+        }
+    }
+
 }

+ 55 - 0
service/service-order/src/main/resources/mapper/OrderInfoMapper.xml

@@ -4,7 +4,62 @@
 
 <mapper namespace="com.atguigu.tingshu.order.mapper.OrderInfoMapper">
 
+    <!--定义结果集封装一对多-->
+    <resultMap id="orderInfoMap" type="com.atguigu.tingshu.model.order.OrderInfo" autoMapping="true">
+        <!--封装一方-->
+        <id property="id" column="id"></id>
+        <!--封装多方-->
+        <collection property="orderDetailList" ofType="com.atguigu.tingshu.model.order.OrderDetail" autoMapping="true">
+            <id property="id" column="order_detail_id"></id>
+        </collection>
+    </resultMap>
 
+    <!--订单跟订单明细一对多-->
+    <select id="findUserOrderPage1" resultMap="orderInfoMap">
+        select
+            oi.id,
+            oi.order_no,
+            oi.order_status,
+            oi.original_amount,
+            oi.derate_amount,
+            oi.order_amount,
+            oi.pay_way,
+            od.id order_detail_id,
+            od.item_name,
+            od.item_price,
+            od.item_url
+        from order_info oi inner join  order_detail od
+                                       on od.order_id = oi.id and od.is_deleted = 0
+        where oi.user_id = 26 and oi.is_deleted = 0
+        order by oi.id desc
+    </select>
 
+
+
+    <resultMap id="orderInfoResultMap" type="com.atguigu.tingshu.model.order.OrderInfo" autoMapping="true">
+        <id property="id" column="id"></id>
+        <!--订单明细列表 select指定查询ID(查询订单明细)-->
+        <collection property="orderDetailList" column="id" select="getOrderDetailById"></collection>
+    </resultMap>
+
+    <!--根据订单ID查询订单明细列表-->
+    <select id="getOrderDetailById" resultType="com.atguigu.tingshu.model.order.OrderDetail">
+        select id,item_id,item_name,item_price,item_url from order_detail where order_id = #{id}
+    </select>
+
+    <!--分页查询订单列表-->
+    <select id="findUserOrderPage" resultMap="orderInfoResultMap">
+        select oi.id,
+               oi.order_no,
+               oi.order_status,
+               oi.original_amount,
+               oi.derate_amount,
+               oi.order_amount,
+               oi.pay_way
+        from order_info oi
+        where user_id = #{userId}
+          and oi.is_deleted = 0
+        order by oi.id desc
+    </select>
 </mapper>
 

+ 42 - 2
service/service-payment/src/main/java/com/atguigu/tingshu/payment/api/WxPayApiController.java

@@ -1,11 +1,16 @@
 package com.atguigu.tingshu.payment.api;
 
+import com.atguigu.tingshu.common.login.GuiGuLogin;
+import com.atguigu.tingshu.common.result.Result;
+import com.atguigu.tingshu.common.util.AuthContextHolder;
 import com.atguigu.tingshu.payment.service.WxPayService;
+import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.Map;
 
 @Tag(name = "微信支付接口")
 @RestController
@@ -16,4 +21,39 @@ public class WxPayApiController {
     @Autowired
     private WxPayService wxPayService;
 
+
+    /**
+     * 获取小程序拉起微信支付所需参数
+     * @param paymentType 支付类型 1301-订单 1302-充值
+     * @param orderNo 交易订单号或充值订单号
+     * @return {"timeStamp":"","package":"","paySign":"","signType":"RSA","nonceStr":""}
+     */
+    @Operation(summary = "获取小程序拉起微信支付所需参数")
+    @PostMapping("/wxPay/createJsapi/{paymentType}/{orderNo}")
+    public Result<Map<String, String>> createJsapi(
+            @PathVariable("paymentType") String paymentType,
+            @PathVariable("orderNo") String orderNo
+    ){
+        //1.获取用户ID
+        Long userId = AuthContextHolder.getUserId();
+        //2.调用支付业务层对接微信
+        Map<String, String> map = wxPayService.createJsapi(userId, paymentType, orderNo);
+        return Result.ok(map);
+    }
+
+
+    /**
+     * 查询订单交易状态
+     * @param orderNo
+     * @return
+     */
+    @GuiGuLogin
+    @Operation(summary = "查询订单交易状态")
+    @GetMapping("/wxPay/queryPayStatus/{orderNo}")
+    public Result<Boolean> queryPayStatus(@PathVariable("orderNo") String orderNo){
+        //1.调用微信查询订单状态
+        boolean result = wxPayService.queryPayStatus(orderNo);
+        return Result.ok(result);
+    }
+
 }

+ 4 - 2
service/service-payment/src/main/java/com/atguigu/tingshu/payment/config/WxPayV3Config.java

@@ -1,15 +1,17 @@
 package com.atguigu.tingshu.payment.config;
 
 import com.wechat.pay.java.core.RSAAutoCertificateConfig;
-import com.wechat.pay.java.service.payments.jsapi.JsapiServiceExtension;
 import lombok.Data;
 import org.springframework.boot.context.properties.ConfigurationProperties;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 
+/**
+ * 自动刷新配置
+ */
+@Data
 @Configuration
 @ConfigurationProperties(prefix="wechat.v3pay") //读取节点
-@Data
 public class WxPayV3Config {
 
     private String appid;

+ 10 - 0
service/service-payment/src/main/java/com/atguigu/tingshu/payment/service/PaymentInfoService.java

@@ -5,4 +5,14 @@ import com.baomidou.mybatisplus.extension.service.IService;
 
 public interface PaymentInfoService extends IService<PaymentInfo> {
 
+    /**
+     * 保存本地交易记录
+     *
+     * @param paymentType:支付类型 1301-订单 1302-充值
+     * @param orderNo: 订单编号
+     * @return
+     */
+    public PaymentInfo savePaymentInfo(String paymentType, String orderNo);
+
+
 }

+ 16 - 0
service/service-payment/src/main/java/com/atguigu/tingshu/payment/service/WxPayService.java

@@ -1,5 +1,21 @@
 package com.atguigu.tingshu.payment.service;
 
+import java.util.Map;
+
 public interface WxPayService {
 
+    /**
+     * 获取小程序拉起微信支付所需参数
+     * @param paymentType 支付类型 1301-订单 1302-充值
+     * @param orderNo 交易订单号或充值订单号
+     * @return {"timeStamp":"","package":"","paySign":"","signType":"RSA","nonceStr":""}
+     */
+    Map<String, String> createJsapi(Long userId, String paymentType, String orderNo);
+
+    /**
+     * 查询订单交易状态
+     * @param orderNo
+     * @return
+     */
+    boolean queryPayStatus(String orderNo);
 }

+ 80 - 0
service/service-payment/src/main/java/com/atguigu/tingshu/payment/service/impl/PaymentInfoServiceImpl.java

@@ -1,13 +1,93 @@
 package com.atguigu.tingshu.payment.service.impl;
 
+import cn.hutool.core.lang.Assert;
+import com.atguigu.tingshu.account.AccountFeignClient;
+import com.atguigu.tingshu.common.constant.SystemConstant;
+import com.atguigu.tingshu.common.execption.GuiguException;
+import com.atguigu.tingshu.model.account.RechargeInfo;
+import com.atguigu.tingshu.model.order.OrderInfo;
 import com.atguigu.tingshu.model.payment.PaymentInfo;
+import com.atguigu.tingshu.order.client.OrderFeignClient;
 import com.atguigu.tingshu.payment.mapper.PaymentInfoMapper;
 import com.atguigu.tingshu.payment.service.PaymentInfoService;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import static com.atguigu.tingshu.common.constant.SystemConstant.ORDER_STATUS_CANCEL;
+import static com.atguigu.tingshu.common.constant.SystemConstant.ORDER_STATUS_PAID;
+
 @Service
 @SuppressWarnings({"all"})
 public class PaymentInfoServiceImpl extends ServiceImpl<PaymentInfoMapper, PaymentInfo> implements PaymentInfoService {
 
+    @Autowired
+    private OrderFeignClient orderFeignClient;
+
+    @Autowired
+    private AccountFeignClient accountFeignClient;
+
+    /**
+     * 保存本地交易记录
+     *
+     * @param paymentType:支付类型 1301-订单 1302-充值
+     * @param orderNo:         订单编号
+     * @return
+     */
+    @Override
+    public PaymentInfo savePaymentInfo(String paymentType, String orderNo) {
+        //1. 根据订单编号查询本地交易记录 ,如果存在返回即可
+        PaymentInfo paymentInfo = baseMapper.selectOne(
+                new LambdaQueryWrapper<PaymentInfo>().eq(PaymentInfo::getOrderNo, orderNo)
+        );
+        if (paymentInfo != null) {
+            return paymentInfo;
+        }
+        //2. 本地交易记录不存在,封装保存本地交易记录
+        //2.1 创建本地交易记录对象
+        paymentInfo = new PaymentInfo();
+        //2.2 处理支付类型订单:封装交易金额跟内容
+        if (SystemConstant.PAYMENT_TYPE_ORDER.equals(paymentType)) {
+            //2.2.1 远程调用订单服务获取订单信息,封装交易金额跟内容
+            OrderInfo orderInfo = orderFeignClient.getOrderInfo(orderNo).getData();
+            Assert.notNull(orderInfo, "订单:{}不存在", orderNo);
+            //2.2.2 判断订单状态:如果订单状态为已支付或已取消,则终止业务 订单状态:0901-未支付 0902-已支付 0903-已取消
+            String orderStatus = orderInfo.getOrderStatus();
+            if (ORDER_STATUS_PAID.equals(orderStatus) || ORDER_STATUS_CANCEL.equals(orderStatus)) {
+                throw new GuiguException(500, "订单状态有误:已支付或已取消");
+            }
+            //2.2.3 封装交易金额跟内容
+            paymentInfo.setUserId(orderInfo.getUserId());
+            paymentInfo.setAmount(orderInfo.getOrderAmount());
+            paymentInfo.setContent(orderInfo.getOrderTitle());
+        }
+        if (SystemConstant.PAYMENT_TYPE_RECHARGE.equals(paymentType)) {
+            //2.3 处理支付类型充值:封装交易金额跟内容
+            //2.3.1 远程调用账户服务获取充值信息,封装交易金额跟内容
+            RechargeInfo rechargeInfo = accountFeignClient.getRechargeInfo(orderNo).getData();
+            Assert.notNull(rechargeInfo, "充值:{}不存在", orderNo);
+            //2.3.2 判断订单状态:如果订单状态为已支付或已取消,则终止业务 充值状态:0901-未支付 0902-已支付 0903-已取消
+            String rechargeStatus = rechargeInfo.getRechargeStatus();
+            if (ORDER_STATUS_PAID.equals(rechargeStatus) || ORDER_STATUS_CANCEL.equals(rechargeStatus)) {
+                throw new GuiguException(500, "充值状态有误:已支付或已取消");
+            }
+            //2.3.3 封装交易金额跟内容
+            paymentInfo.setUserId(rechargeInfo.getUserId());
+            paymentInfo.setAmount(rechargeInfo.getRechargeAmount());
+            paymentInfo.setContent("充值:" + rechargeInfo.getRechargeAmount());
+        }
+        paymentInfo.setPaymentType(paymentType);
+        paymentInfo.setOrderNo(orderNo);
+        paymentInfo.setPayWay(SystemConstant.ORDER_PAY_WAY_WEIXIN);
+        //支付状态:1401-未支付 1402-已支付
+        paymentInfo.setPaymentStatus(SystemConstant.PAYMENT_STATUS_UNPAID);
+        //TODO 本地交易记录中:微信端交易编号、回调时间及内容 支付成功后商户收到回调通知才更新
+        //paymentInfo.setOutTradeNo();
+        //paymentInfo.setCallbackTime();
+        //paymentInfo.setCallbackContent();
+        //2.4 保存本地交易记录
+        baseMapper.insert(paymentInfo);
+        return paymentInfo;
+    }
 }

+ 103 - 2
service/service-payment/src/main/java/com/atguigu/tingshu/payment/service/impl/WxPayServiceImpl.java

@@ -1,16 +1,117 @@
 package com.atguigu.tingshu.payment.service.impl;
 
+import com.atguigu.tingshu.common.constant.SystemConstant;
+import com.atguigu.tingshu.common.execption.GuiguException;
+import com.atguigu.tingshu.model.payment.PaymentInfo;
+import com.atguigu.tingshu.payment.config.WxPayV3Config;
 import com.atguigu.tingshu.payment.service.PaymentInfoService;
 import com.atguigu.tingshu.payment.service.WxPayService;
+import com.wechat.pay.java.core.RSAAutoCertificateConfig;
+import com.wechat.pay.java.service.payments.jsapi.JsapiServiceExtension;
+import com.wechat.pay.java.service.payments.jsapi.model.*;
+import com.wechat.pay.java.service.payments.model.Transaction;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.HashMap;
+import java.util.Map;
+
 @Service
 @Slf4j
 public class WxPayServiceImpl implements WxPayService {
 
-	@Autowired
-	private PaymentInfoService paymentInfoService;
+    @Autowired
+    private PaymentInfoService paymentInfoService;
+
+    @Autowired
+    private RSAAutoCertificateConfig config;
+
+    @Autowired
+    private WxPayV3Config wxPayV3Config;
+
+    /**
+     * 获取小程序拉起微信支付所需参数
+     *
+     * @param paymentType 支付类型 1301-订单 1302-充值
+     * @param orderNo     交易订单号或充值订单号
+     * @return {"timeStamp":"","package":"","paySign":"","signType":"RSA","nonceStr":""}
+     */
+    @Override
+    public Map<String, String> createJsapi(Long userId, String paymentType, String orderNo) {
+        //1.保存封装本地交易记录
+        PaymentInfo paymentInfo = paymentInfoService.savePaymentInfo(paymentType, orderNo);
+        //支付状态:1401-未支付 1402-已支付
+        String paymentStatus = paymentInfo.getPaymentStatus();
+        //判断本地交易支付状态
+        if (SystemConstant.PAYMENT_STATUS_PAID.equals(paymentStatus)) {
+            throw new GuiguException(500, "当前交易已支付");
+        }
+
+        //2.TODO 对接微信支付接口获取小程序拉起微信支付相关参数
+        //2.1 构建支付service对象
+        JsapiServiceExtension service =
+                new JsapiServiceExtension.Builder().config(config).build();
+
+        //2.2 创建预支付请求对象 用于产生微信交易
+        PrepayRequest request = new PrepayRequest();
+        Amount amount = new Amount();
+        //TODO 开发中将应付金额设置为1分
+        amount.setTotal(1);
+        //amount.setTotal(paymentInfo.getAmount());
+        request.setAmount(amount);
+        request.setAppid(wxPayV3Config.getAppid());
+        request.setMchid(wxPayV3Config.getMerchantId());
+        request.setDescription(paymentInfo.getContent());
+        request.setNotifyUrl(wxPayV3Config.getNotifyUrl());
+        request.setOutTradeNo(paymentInfo.getOrderNo());
+        //TODO 小程序还未上线,只允许应用下开发者用户付款 设置付款者唯一标识
+        Payer payer = new Payer();
+        payer.setOpenid("odo3j4qp-wC3HVq9Z_D9C0cOr0Zs");
+        request.setPayer(payer);
+        //2.3 调用下单方法,得到响应,封装调起支付的参数
+        PrepayWithRequestPaymentResponse response = service.prepayWithRequestPayment(request);
+        if (response != null) {
+            String timeStamp = response.getTimeStamp();
+            String nonceStr = response.getNonceStr();
+            String packageVal = response.getPackageVal();
+            String signType = response.getSignType();
+            String paySign = response.getPaySign();
+            Map<String, String> map = new HashMap<>();
+            map.put("timeStamp", timeStamp);
+            map.put("nonceStr", nonceStr);
+            map.put("package", packageVal);
+            map.put("signType", signType);
+            map.put("paySign", paySign);
+            return map;
+        }
+        return null;
+    }
 
+    /**
+     * 查询订单交易状态
+     *
+     * @param orderNo
+     * @return
+     */
+    @Override
+    public boolean queryPayStatus(String orderNo) {
+        //1.构建支付service对象
+        JsapiServiceExtension service =
+                new JsapiServiceExtension.Builder().config(config).build();
+        //2.根据商户侧订单编号查询交易
+        QueryOrderByOutTradeNoRequest request = new QueryOrderByOutTradeNoRequest();
+        request.setMchid(wxPayV3Config.getMerchantId());
+        request.setOutTradeNo(orderNo);
+        Transaction transaction = service.queryOrderByOutTradeNo(request);
+        //3.判断交易状态
+        if (transaction != null) {
+            log.info("订单对应交易结果:{}" + transaction);
+            Transaction.TradeStateEnum tradeState = transaction.getTradeState();
+            if (Transaction.TradeStateEnum.SUCCESS == tradeState) {
+                return true;
+            }
+        }
+        return false;
+    }
 }