|
@@ -2,6 +2,7 @@ package cn.rankin.cmsweb.service.trade.order;
|
|
|
|
|
|
import cn.rankin.cmsweb.code.CmsWebAPICode;
|
|
|
import cn.rankin.cmsweb.service.product.GoodsService;
|
|
|
+import cn.rankin.cmsweb.service.product.ProductService;
|
|
|
import cn.rankin.cmsweb.service.user.CampusService;
|
|
|
import cn.rankin.cmsweb.service.user.MerchantService;
|
|
|
import cn.rankin.cmsweb.service.user.TerminalUserService;
|
|
@@ -16,6 +17,7 @@ import cn.rankin.data.api.cms.OrderSearchWebDTO;
|
|
|
import cn.rankin.data.api.cms.OrderSnapshotWebSearchDTO;
|
|
|
import cn.rankin.data.api.product.entity.Goods;
|
|
|
import cn.rankin.data.api.product.vo.GoodsVo;
|
|
|
+import cn.rankin.data.api.product.vo.ProductVo;
|
|
|
import cn.rankin.data.api.trade.dto.OrderDTO;
|
|
|
import cn.rankin.data.api.trade.dto.OrderDetailSearchDTO;
|
|
|
import cn.rankin.data.api.trade.dto.OrderGoodsDTO;
|
|
@@ -31,6 +33,7 @@ import cn.rankin.data.api.user.dto.CampusSearchDTO;
|
|
|
import cn.rankin.data.api.user.dto.PayDTO;
|
|
|
import cn.rankin.data.api.user.vo.CampusVo;
|
|
|
import cn.rankin.data.api.user.vo.TerminalUserVo;
|
|
|
+import com.sun.tools.hat.internal.model.HackJavaValue;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -68,6 +71,9 @@ public class OrderService {
|
|
|
@Autowired
|
|
|
private MerchantService merchantService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ProductService productService;
|
|
|
+
|
|
|
// 支付
|
|
|
public APIResult<Boolean> pay(String orderId) {
|
|
|
APIResult<Order> userOrderAPIResult = orderClient.getOrder(orderId);
|
|
@@ -268,14 +274,34 @@ public class OrderService {
|
|
|
}
|
|
|
|
|
|
public List<OrderGoodsVo> toOrderGoodsVo(List<OrderGoods> orderGoodsList) {
|
|
|
+ if (CollectionUtils.isEmpty(orderGoodsList)) {
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
List<String> goodsIdList = new ArrayList<>();
|
|
|
- orderGoodsList.forEach(orderGoods -> goodsIdList.add(orderGoods.getGoodsId()));
|
|
|
+ List<String> productIdList = new ArrayList<>();
|
|
|
+ orderGoodsList.forEach(orderGoods -> {
|
|
|
+ goodsIdList.add(orderGoods.getGoodsId());
|
|
|
+ productIdList.add(orderGoods.getPid());
|
|
|
+ });
|
|
|
+
|
|
|
APIResult<List<GoodsVo>> goodsAPIResult = goodsService.findByIds(goodsIdList);
|
|
|
if (!goodsAPIResult.getSuccess()) {
|
|
|
log.error("goods api error: {}", goodsAPIResult.getMessage());
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ APIResult<List<ProductVo>> productAPIResult = productService.findProductByIds(productIdList);
|
|
|
+ if (!productAPIResult.getSuccess()) {
|
|
|
+ log.error("product api error: {}", productAPIResult.getMessage());
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<ProductVo> productVoList = productAPIResult.getData();
|
|
|
+ Map<String, ProductVo> productVoMap = new HashMap<>();
|
|
|
+ for (ProductVo productVo : productVoList) {
|
|
|
+ productVoMap.put(productVo.getPid(), productVo);
|
|
|
+ }
|
|
|
+
|
|
|
List<GoodsVo> goodsVoList = goodsAPIResult.getData();
|
|
|
Map<String, GoodsVo> goodsVoMap = new HashMap<>();
|
|
|
for (GoodsVo goodsVo : goodsVoList) {
|
|
@@ -285,6 +311,7 @@ public class OrderService {
|
|
|
List<OrderGoodsVo> orderGoodsVoList = new ArrayList<>();
|
|
|
for (OrderGoods orderGoods : orderGoodsList) {
|
|
|
String goodsId = orderGoods.getGoodsId();
|
|
|
+ String productId = orderGoods.getPid();
|
|
|
|
|
|
OrderGoodsVo orderGoodsVo = new OrderGoodsVo();
|
|
|
BeanUtils.copyProperties(orderGoods, orderGoodsVo);
|
|
@@ -297,6 +324,12 @@ public class OrderService {
|
|
|
BeanUtils.copyProperties(goodsVo, orderGoodsVo);
|
|
|
goodsVo.setId(orderGoods.getId());
|
|
|
|
|
|
+ ProductVo productVo = productVoMap.get(productId);
|
|
|
+ if (productVo != null) {
|
|
|
+ orderGoodsVo.setName(productVo.getName());
|
|
|
+ orderGoodsVo.setCode(productVo.getCode());
|
|
|
+ }
|
|
|
+
|
|
|
orderGoodsVoList.add(orderGoodsVo);
|
|
|
}
|
|
|
return orderGoodsVoList;
|