|
@@ -3,24 +3,21 @@ 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 cn.hutool.core.util.IdUtil;
|
|
|
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.result.Result;
|
|
|
import com.atguigu.tingshu.common.util.AuthContextHolder;
|
|
|
-import com.atguigu.tingshu.model.album.AlbumInfo;
|
|
|
-import com.atguigu.tingshu.model.album.TrackInfo;
|
|
|
import com.atguigu.tingshu.model.order.OrderDerate;
|
|
|
import com.atguigu.tingshu.model.order.OrderDetail;
|
|
|
import com.atguigu.tingshu.model.order.OrderInfo;
|
|
|
-import com.atguigu.tingshu.model.user.VipServiceConfig;
|
|
|
import com.atguigu.tingshu.order.helper.SignHelper;
|
|
|
import com.atguigu.tingshu.order.mapper.OrderDerateMapper;
|
|
|
import com.atguigu.tingshu.order.mapper.OrderDetailMapper;
|
|
|
import com.atguigu.tingshu.order.mapper.OrderInfoMapper;
|
|
|
+import com.atguigu.tingshu.order.pattern.factory.TradeOrderStrategyFactory;
|
|
|
+import com.atguigu.tingshu.order.pattern.strategy.TradeOrderStrategy;
|
|
|
import com.atguigu.tingshu.order.service.OrderDetailService;
|
|
|
import com.atguigu.tingshu.order.service.OrderInfoService;
|
|
|
import com.atguigu.tingshu.user.client.UserFeignClient;
|
|
@@ -29,7 +26,6 @@ import com.atguigu.tingshu.vo.order.OrderDerateVo;
|
|
|
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.UserInfoVo;
|
|
|
import com.atguigu.tingshu.vo.user.UserPaidRecordVo;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -40,10 +36,9 @@ import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.data.redis.core.script.DefaultRedisScript;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.math.BigDecimal;
|
|
|
-import java.math.RoundingMode;
|
|
|
-import java.util.*;
|
|
|
-import java.util.concurrent.TimeUnit;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import static com.atguigu.tingshu.common.constant.SystemConstant.*;
|
|
@@ -77,7 +72,21 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|
|
@Autowired
|
|
|
private AccountFeignClient accountFeignClient;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private TradeOrderStrategyFactory tradeOrderStrategyFactory;
|
|
|
+
|
|
|
|
|
|
+ @Override
|
|
|
+ public OrderInfoVo trade(Long userId, TradeVo tradeVo) {
|
|
|
+ //1.创建订单VO
|
|
|
+ OrderInfoVo orderInfoVo = new OrderInfoVo();
|
|
|
+ //2.获取购买商品类别:付款项目类型: 1001-专辑 1002-声音 1003-vip会员
|
|
|
+ String itemType = tradeVo.getItemType();
|
|
|
+ //3.从工厂获取策略实现类对象
|
|
|
+ TradeOrderStrategy tradeOrderStrategy = tradeOrderStrategyFactory.getTradeOrderStrategy(itemType);
|
|
|
+ tradeOrderStrategy.handleTrade(tradeVo, orderInfoVo);
|
|
|
+ return orderInfoVo;
|
|
|
+ }
|
|
|
/**
|
|
|
* 对购买商品(VIP会员、专辑、声音)封装订单结算页所需要数据
|
|
|
*
|
|
@@ -85,11 +94,13 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|
|
* @param tradeVo {购买商品类别,商品ID,声音数量}
|
|
|
* @return
|
|
|
*/
|
|
|
- @Override
|
|
|
+ /*@Override
|
|
|
public OrderInfoVo trade(Long userId, TradeVo tradeVo) {
|
|
|
//1.创建订单VO
|
|
|
OrderInfoVo orderInfoVo = new OrderInfoVo();
|
|
|
|
|
|
+ //获取购买商品类别:付款项目类型: 1001-专辑 1002-声音 1003-vip会员
|
|
|
+ String itemType = tradeVo.getItemType();
|
|
|
//1.1.初始化订单结算页三个价格:原价、减免价、订单价
|
|
|
BigDecimal originalAmount = new BigDecimal("0.00");
|
|
|
BigDecimal derateAmount = new BigDecimal("0.00");
|
|
@@ -98,8 +109,6 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|
|
List<OrderDetailVo> orderDetailVoList = new ArrayList<>();
|
|
|
List<OrderDerateVo> orderDerateVoList = new ArrayList<>();
|
|
|
|
|
|
- //获取购买商品类别:付款项目类型: 1001-专辑 1002-声音 1003-vip会员
|
|
|
- String itemType = tradeVo.getItemType();
|
|
|
//2.处理购买商品类别:VIP套餐
|
|
|
if (ORDER_ITEM_TYPE_VIP.equals(itemType)) {
|
|
|
//2.1 远程调用"用户服务"获取套餐详情
|
|
@@ -238,7 +247,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|
|
orderInfoVo.setSign(sign);
|
|
|
//6.响应订单VO
|
|
|
return orderInfoVo;
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
/**
|
|
|
* 提交订单
|