|
@@ -0,0 +1,492 @@
|
|
|
+package cn.rankin.task.task.order;
|
|
|
+
|
|
|
+import cn.rankin.common.utils.api.model.APIResult;
|
|
|
+import cn.rankin.common.utils.constant.Constant;
|
|
|
+import cn.rankin.common.utils.enums.BaseStatusEnum;
|
|
|
+import cn.rankin.common.utils.enums.OrderDetailTypeEnum;
|
|
|
+import cn.rankin.common.utils.enums.ProductTypeEnum;
|
|
|
+import cn.rankin.data.api.auth.dto.AuthDTO;
|
|
|
+import cn.rankin.data.api.product.entity.Goods;
|
|
|
+import cn.rankin.data.api.product.entity.Product;
|
|
|
+import cn.rankin.data.api.trade.entity.OrderDetail;
|
|
|
+import cn.rankin.data.api.trade.entity.OrderGoods;
|
|
|
+import cn.rankin.data.api.trade.entity.OrderProductSnapshot;
|
|
|
+import cn.rankin.data.api.user.entity.Merchant;
|
|
|
+import cn.rankin.data.api.user.vo.CampusVo;
|
|
|
+import cn.rankin.data.api.user.vo.TerminalUserVo;
|
|
|
+import cn.rankin.task.service.AuthService;
|
|
|
+import cn.rankin.task.service.OrderService;
|
|
|
+import cn.rankin.task.service.ProductService;
|
|
|
+import cn.rankin.task.service.UserService;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+@Slf4j
|
|
|
+@Component
|
|
|
+public class OrderDetailCompleteTask {
|
|
|
+
|
|
|
+ public final static long INTERVAL = 10 * 1000;
|
|
|
+
|
|
|
+ public final static Integer SIZE = 100;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private UserService userService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ProductService productService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private OrderService orderService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private AuthService authService;
|
|
|
+
|
|
|
+ @Scheduled(fixedDelay = INTERVAL)
|
|
|
+ public void run() {
|
|
|
+ log.info("{} start", this.getClass().getName());
|
|
|
+
|
|
|
+ List<OrderDetail> orderDetailList = orderService.findOrderDetailForCompleteList(SIZE);
|
|
|
+ if (orderDetailList.size() == 0) {
|
|
|
+ log.info("load detail order for complete is empty");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ log.info("load detail order for complete num={}", orderDetailList.size());
|
|
|
+
|
|
|
+ // 获取所有goodsId and userId
|
|
|
+ List<String> goodsIdList = new ArrayList<>();
|
|
|
+ List<String> userIdList = new ArrayList<>();
|
|
|
+ for (OrderDetail orderDetail : orderDetailList) {
|
|
|
+ String userId = orderDetail.getUid();
|
|
|
+ if (!userIdList.contains(userId)) {
|
|
|
+ userIdList.add(userId);
|
|
|
+ }
|
|
|
+ List<OrderGoods> orderGoodsList = orderDetail.getGoods();
|
|
|
+ for (OrderGoods orderGoods : orderGoodsList) {
|
|
|
+ String goodsId = orderGoods.getGoodsId();
|
|
|
+ if (!goodsIdList.contains(goodsId)) {
|
|
|
+ goodsIdList.add(orderGoods.getGoodsId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取所有商品信息
|
|
|
+ List<Goods> goodsList = this.loadGoods(goodsIdList);
|
|
|
+ if (CollectionUtils.isEmpty(goodsList)) {
|
|
|
+ log.error("load total goods info error");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Goods> goodsMap = new HashMap<>();
|
|
|
+ for (Goods goods : goodsList) {
|
|
|
+ String goodsId = goods.getId();
|
|
|
+ goodsMap.put(goodsId, goods);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取用户信息
|
|
|
+ List<TerminalUserVo> terminalUserVoList = this.loadUsers(userIdList);
|
|
|
+ if (CollectionUtils.isEmpty(terminalUserVoList)) {
|
|
|
+ log.error("load user info error");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<String> campusIdList = new ArrayList<>();
|
|
|
+ Map<String, TerminalUserVo> terminalUserVoMap = new HashMap<>();
|
|
|
+ for (TerminalUserVo terminalUserVo : terminalUserVoList) {
|
|
|
+ String campusId = terminalUserVo.getCampusId();
|
|
|
+ if (!campusIdList.contains(campusId)) {
|
|
|
+ campusIdList.add(campusId);
|
|
|
+ }
|
|
|
+ terminalUserVoMap.put(terminalUserVo.getId(), terminalUserVo);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取校区信息
|
|
|
+ Map<String, CampusVo> campusVoMap = this.loadCampus(campusIdList);
|
|
|
+ if (CollectionUtils.isEmpty(campusVoMap)) {
|
|
|
+ log.error("load campus info error");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (OrderDetail orderDetail : orderDetailList) {
|
|
|
+ String detailId = orderDetail.getId();
|
|
|
+ OrderDetailTypeEnum type = orderDetail.getType();
|
|
|
+
|
|
|
+ // 更新状态
|
|
|
+ Boolean success = orderService.completeDetail(detailId);
|
|
|
+ if (!success) {
|
|
|
+ log.error("分拆订单完成状态标记失败, detailId={}", detailId);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<AuthDTO> authList = new ArrayList<>();
|
|
|
+ if (type.equals(OrderDetailTypeEnum.VIRTUAL)) {
|
|
|
+ // 要进行鉴权记录插入, 课程包按包级别插入, 不分解
|
|
|
+ String uid = orderDetail.getUid();
|
|
|
+ List<OrderGoods> orderGoodsList = orderDetail.getGoods();
|
|
|
+ for (OrderGoods orderGoods : orderGoodsList) {
|
|
|
+ String goodsId = orderGoods.getGoodsId();
|
|
|
+ Goods goods = goodsMap.get(goodsId);
|
|
|
+ if (goods == null) {
|
|
|
+ log.error("goods not found, detailId={}, goodsId={}", detailId, goodsId);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ AuthDTO authDTO = new AuthDTO();
|
|
|
+ authDTO.setUid(uid);
|
|
|
+ authDTO.setPid(orderGoods.getPid());
|
|
|
+ // 要乘数量
|
|
|
+ authDTO.setAddDays(goods.getDuration() * orderGoods.getQuantity());
|
|
|
+ authDTO.setType(Constant.ProductType.COURSE);
|
|
|
+ authDTO.setBizCode(Constant.BIZ_CODE);
|
|
|
+ authDTO.setTitle(String.format("%s_%s", detailId, goodsId));
|
|
|
+ authList.add(authDTO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 加入鉴权记录
|
|
|
+ if (authList.size() > 0) {
|
|
|
+ for (AuthDTO authDTO : authList) {
|
|
|
+ log.info(JSON.toJSONString(authDTO));
|
|
|
+ APIResult authResult = authService.add(authDTO);
|
|
|
+ if (!authResult.getSuccess()) {
|
|
|
+ log.error("add auth list error, detailId={}", detailId);
|
|
|
+ } else {
|
|
|
+ log.info("add auth list success, detailId={}", detailId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 放入交易快照
|
|
|
+ String userId = orderDetail.getUid();
|
|
|
+ TerminalUserVo terminalUserVo = terminalUserVoMap.get(userId);
|
|
|
+ if (terminalUserVo == null) {
|
|
|
+ log.error("userInfo is null, detailId={}, userId={}", detailId, userId);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ String campusId = terminalUserVo.getCampusId();
|
|
|
+ CampusVo campusVo = campusVoMap.get(campusId);
|
|
|
+ if (campusVo == null) {
|
|
|
+ log.error("campus info is null, detailId={}, userId={}", detailId, campusId);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ List<OrderProductSnapshot> snapshotList = this.toSnaptshots(orderDetail, terminalUserVo, campusVo, goodsList);
|
|
|
+
|
|
|
+ List<OrderGoods> orderGoodsList = orderDetail.getGoods();
|
|
|
+ for (OrderGoods orderGoods : orderGoodsList) {
|
|
|
+ String goodsId = orderGoods.getGoodsId();
|
|
|
+ ProductTypeEnum productType = orderGoods.getType();
|
|
|
+ if (productType.equals(ProductTypeEnum.PACKAGE)) {
|
|
|
+ Goods packageGoods = goodsMap.get(goodsId);
|
|
|
+ if (packageGoods == null) {
|
|
|
+ log.error("detail order goods is null, detailId={}, goodsId={}", detailId, goodsId);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ List<OrderProductSnapshot> packageSnapshotList = this.toSnaptshots(orderGoods, terminalUserVo, campusVo, packageGoods);
|
|
|
+ snapshotList.addAll(packageSnapshotList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ orderService.insertSnapshots(snapshotList);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<OrderProductSnapshot> toSnaptshots(OrderDetail detailOrder, TerminalUserVo terminalUserVo, CampusVo campusVo,
|
|
|
+ List<Goods> goodsList) {
|
|
|
+ List<OrderProductSnapshot> snapshotList = new ArrayList<>();
|
|
|
+ String orderId = detailOrder.getOrderId();
|
|
|
+ String merchantId = campusVo.getMerchantId();
|
|
|
+ String detailId = detailOrder.getId();
|
|
|
+ String userId = detailOrder.getUid();
|
|
|
+ String userName = terminalUserVo.getName();
|
|
|
+ String userCode = terminalUserVo.getCode();
|
|
|
+ String campusId = campusVo.getId();
|
|
|
+ String campusCode = campusVo.getCode();
|
|
|
+ String campusName = campusVo.getName();
|
|
|
+
|
|
|
+ List<String> productIdList = new ArrayList<>();
|
|
|
+ List<OrderGoods> orderGoodsList = detailOrder.getGoods();
|
|
|
+
|
|
|
+ for (OrderGoods orderGoods : orderGoodsList) {
|
|
|
+ String productId = orderGoods.getPid();
|
|
|
+ if (!productIdList.contains(productId)) {
|
|
|
+ productIdList.add(productId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Goods> goodsMap = new HashMap<>();
|
|
|
+ goodsList.forEach(goods -> goodsMap.put(goods.getId(), goods));
|
|
|
+
|
|
|
+ List<String> merchantIdList = new ArrayList<>();
|
|
|
+ for (Goods goods : goodsList) {
|
|
|
+ String cpId = goods.getCpId();
|
|
|
+ if (!merchantIdList.contains(cpId)) {
|
|
|
+ merchantIdList.add(cpId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ merchantIdList.add(merchantId);
|
|
|
+
|
|
|
+ Map<String, Merchant> merchantMap = this.loadMerchants(merchantIdList);
|
|
|
+ if (CollectionUtils.isEmpty(merchantMap)) {
|
|
|
+ log.error("load merchant info error, detailId={}", detailId);
|
|
|
+ }
|
|
|
+ Merchant merchant = merchantMap.get(merchantId);
|
|
|
+ String merchantName = merchant == null ? "" : merchant.getName();
|
|
|
+
|
|
|
+ Map<String, Product> productMap = this.loadProducts(productIdList);
|
|
|
+ if (CollectionUtils.isEmpty(productMap)) {
|
|
|
+ log.error("load product info error, detailId={}", detailId);
|
|
|
+ }
|
|
|
+
|
|
|
+ for (OrderGoods orderGoods : orderGoodsList) {
|
|
|
+ String goodsId = orderGoods.getGoodsId();
|
|
|
+ String productId = orderGoods.getPid();
|
|
|
+ Integer quantity = orderGoods.getQuantity();
|
|
|
+ Goods goods = goodsMap.get(goodsId);
|
|
|
+ Product product = productMap.get(productId);
|
|
|
+
|
|
|
+ if (goods == null || product == null) {
|
|
|
+ log.error("goods is null or product is null, detailId={}, goodsId={}", detailId, goodsId);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ OrderProductSnapshot snapshot = new OrderProductSnapshot();
|
|
|
+ snapshot.setUid(userId);
|
|
|
+ snapshot.setUserCode(userCode);
|
|
|
+ snapshot.setUserName(userName);
|
|
|
+
|
|
|
+ snapshot.setCampusId(campusId);
|
|
|
+ snapshot.setCampusCode(campusCode);
|
|
|
+ snapshot.setCampusName(campusName);
|
|
|
+
|
|
|
+ snapshot.setOrderId(orderId);
|
|
|
+ snapshot.setDetailId(detailId);
|
|
|
+
|
|
|
+ snapshot.setPid(product.getPid());
|
|
|
+ snapshot.setProductCode(product.getCode());
|
|
|
+ snapshot.setProductName(product.getName());
|
|
|
+ snapshot.setProductType(product.getType());
|
|
|
+
|
|
|
+ snapshot.setMerchantId(merchantId);
|
|
|
+ snapshot.setMerchantName(merchantName);
|
|
|
+
|
|
|
+ snapshot.setGoodsId(goodsId);
|
|
|
+ snapshot.setDuration(goods.getDuration());
|
|
|
+ snapshot.setCpPrice(goods.getCpPrice());
|
|
|
+ snapshot.setTerminalPrice(goods.getTerminalPrice());
|
|
|
+ snapshot.setMerchantPrice(goods.getMerchantPrice());
|
|
|
+ snapshot.setChargeUnit(goods.getChargeUnit());
|
|
|
+ snapshot.setQuantity(quantity);
|
|
|
+ snapshot.setStatus(BaseStatusEnum.NORMAL);
|
|
|
+
|
|
|
+ String cpId = product.getCpId();
|
|
|
+ snapshot.setCpId(cpId);
|
|
|
+ Merchant cpMerchant = merchantMap.get(cpId);
|
|
|
+ String cpName = cpMerchant == null ? "" : cpMerchant.getName();
|
|
|
+ snapshot.setCpName(cpName);
|
|
|
+
|
|
|
+ snapshotList.add(snapshot);
|
|
|
+ }
|
|
|
+
|
|
|
+ return snapshotList;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public List<OrderProductSnapshot> toSnaptshots(OrderGoods orderGoods, TerminalUserVo terminalUserVo, CampusVo campusVo,
|
|
|
+ Goods packageGoods) {
|
|
|
+ List<OrderProductSnapshot> snapshotList = new ArrayList<>();
|
|
|
+ String orderId = orderGoods.getOrderId();
|
|
|
+ String pkgId = orderGoods.getPid();
|
|
|
+ String merchantId = campusVo.getMerchantId();
|
|
|
+ String detailId = orderGoods.getId();
|
|
|
+ String userId = terminalUserVo.getId();
|
|
|
+ String userName = terminalUserVo.getName();
|
|
|
+ String userCode = terminalUserVo.getCode();
|
|
|
+ String campusId = campusVo.getId();
|
|
|
+ String campusCode = campusVo.getCode();
|
|
|
+ String campusName = campusVo.getName();
|
|
|
+ Integer quantity = orderGoods.getQuantity();
|
|
|
+ Integer duration = packageGoods.getDuration();
|
|
|
+
|
|
|
+ List<Goods> goodsList = this.loadPackageGoods(pkgId, merchantId);
|
|
|
+
|
|
|
+ List<String> productIdList = new ArrayList<>();
|
|
|
+ Map<String, Goods> goodsMap = new HashMap<>();
|
|
|
+ List<String> merchantIdList = new ArrayList<>();
|
|
|
+
|
|
|
+ for (Goods goods : goodsList) {
|
|
|
+ String cpId = goods.getCpId();
|
|
|
+ if (!merchantIdList.contains(cpId)) {
|
|
|
+ merchantIdList.add(cpId);
|
|
|
+ }
|
|
|
+ String productId = goods.getPid();
|
|
|
+ if (!productIdList.contains(productId)) {
|
|
|
+ productIdList.add(productId);
|
|
|
+ }
|
|
|
+ String goodsId = goods.getId();
|
|
|
+ goodsMap.put(goodsId, goods);
|
|
|
+ }
|
|
|
+
|
|
|
+ merchantIdList.add(merchantId);
|
|
|
+
|
|
|
+ Map<String, Merchant> merchantMap = this.loadMerchants(merchantIdList);
|
|
|
+ if (CollectionUtils.isEmpty(merchantMap)) {
|
|
|
+ log.error("load merchant info error, detailId={}", detailId);
|
|
|
+ }
|
|
|
+ Merchant merchant = merchantMap.get(merchantId);
|
|
|
+ String merchantName = merchant == null ? "" : merchant.getName();
|
|
|
+
|
|
|
+ Map<String, Product> productMap = this.loadProducts(productIdList);
|
|
|
+ if (CollectionUtils.isEmpty(productMap)) {
|
|
|
+ log.error("load product info error, detailId={}", detailId);
|
|
|
+ }
|
|
|
+
|
|
|
+ for (Goods goods : goodsList) {
|
|
|
+ ProductTypeEnum productType = goods.getType();
|
|
|
+ if (productType.equals(ProductTypeEnum.SUPPORT)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ String goodsId = goods.getId();
|
|
|
+ String productId = goods.getPid();
|
|
|
+ Product product = productMap.get(productId);
|
|
|
+
|
|
|
+ if (product == null) {
|
|
|
+ log.error("product is null, detailId={}, goodsId={}", detailId, goodsId);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ OrderProductSnapshot snapshot = new OrderProductSnapshot();
|
|
|
+ snapshot.setPkgId(pkgId);
|
|
|
+
|
|
|
+ snapshot.setUid(userId);
|
|
|
+ snapshot.setUserCode(userCode);
|
|
|
+ snapshot.setUserName(userName);
|
|
|
+
|
|
|
+ snapshot.setCampusId(campusId);
|
|
|
+ snapshot.setCampusCode(campusCode);
|
|
|
+ snapshot.setCampusName(campusName);
|
|
|
+
|
|
|
+ snapshot.setOrderId(orderId);
|
|
|
+ snapshot.setDetailId(detailId);
|
|
|
+
|
|
|
+ snapshot.setPid(productId);
|
|
|
+ snapshot.setProductCode(product.getCode());
|
|
|
+ snapshot.setProductName(product.getName());
|
|
|
+ snapshot.setProductType(product.getType());
|
|
|
+
|
|
|
+ snapshot.setMerchantId(merchantId);
|
|
|
+ snapshot.setMerchantName(merchantName);
|
|
|
+
|
|
|
+ snapshot.setGoodsId(goodsId);
|
|
|
+ snapshot.setDuration(duration);
|
|
|
+ snapshot.setCpPrice(goods.getCpPrice());
|
|
|
+ snapshot.setTerminalPrice(goods.getTerminalPrice());
|
|
|
+ snapshot.setMerchantPrice(goods.getMerchantPrice());
|
|
|
+ snapshot.setChargeUnit(goods.getChargeUnit());
|
|
|
+ snapshot.setQuantity(quantity);
|
|
|
+ snapshot.setStatus(BaseStatusEnum.NORMAL);
|
|
|
+
|
|
|
+ String cpId = product.getCpId();
|
|
|
+ snapshot.setCpId(cpId);
|
|
|
+ Merchant cpMerchant = merchantMap.get(cpId);
|
|
|
+ String cpName = cpMerchant == null ? "" : cpMerchant.getName();
|
|
|
+ snapshot.setCpName(cpName);
|
|
|
+
|
|
|
+ snapshotList.add(snapshot);
|
|
|
+ }
|
|
|
+
|
|
|
+ return snapshotList;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Map<String, Merchant> loadMerchants(List<String> merchantIdList) {
|
|
|
+ APIResult<Map<String, Merchant>> apiResult = userService.findMerchantByIds(merchantIdList);
|
|
|
+ if (!apiResult.getSuccess()) {
|
|
|
+ log.error("load merchant error, retry");
|
|
|
+ apiResult = userService.findMerchantByIds(merchantIdList);
|
|
|
+ }
|
|
|
+ return apiResult.getData();
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<TerminalUserVo> loadUsers(List<String> userIdList) {
|
|
|
+ APIResult<List<TerminalUserVo>> apiResult = userService.findUserByIds(userIdList);
|
|
|
+ if (!apiResult.getSuccess()) {
|
|
|
+ log.error("load user error, {}", apiResult.getMessage());
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<TerminalUserVo> terminalUserVoList = apiResult.getData();
|
|
|
+ return terminalUserVoList;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Map<String, CampusVo> loadCampus(List<String> campusIdList) {
|
|
|
+ APIResult<Map<String, CampusVo>> apiResult = userService.findCampusByIds(campusIdList);
|
|
|
+ if (!apiResult.getSuccess()) {
|
|
|
+ log.error("load campus error, {}", apiResult.getMessage());
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return apiResult.getData();
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<Goods> loadPackageGoods(String pkgId, String merchantId) {
|
|
|
+ List<Goods> goodsList = null;
|
|
|
+ int count = 0;
|
|
|
+ while (count < 2) {
|
|
|
+ APIResult<List<Goods>> apiResult = productService.findPackageGoods(pkgId, merchantId);
|
|
|
+ if (apiResult.getSuccess()) {
|
|
|
+ goodsList = apiResult.getData();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ count ++;
|
|
|
+ log.error("load package goods error(times={}), {}", count, apiResult.getMessage());
|
|
|
+ }
|
|
|
+ return goodsList;
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<Goods> loadGoods(List<String> goodsIdList) {
|
|
|
+ List<Goods> goodsList = null;
|
|
|
+ int count = 0;
|
|
|
+ while (count < 2) {
|
|
|
+ APIResult<List<Goods>> apiResult = productService.findGoodsByIds(goodsIdList);
|
|
|
+ if (apiResult.getSuccess()) {
|
|
|
+ goodsList = apiResult.getData();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ count ++;
|
|
|
+ log.error("load goods by ids error(times={}), {}", count, apiResult.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return goodsList;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Map<String, Product> loadProducts(List<String> productIdList) {
|
|
|
+ APIResult<List<Product>> apiResult = productService.findProductByIds(productIdList);
|
|
|
+ if (!apiResult.getSuccess()) {
|
|
|
+ log.error("load products error, {}", apiResult.getMessage());
|
|
|
+ apiResult = productService.findProductByIds(productIdList);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Product> productList = apiResult.getData();
|
|
|
+ if (CollectionUtils.isEmpty(productList)) {
|
|
|
+ return new HashMap<>();
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Product> productMap = new HashMap<>();
|
|
|
+ for (Product product : productList) {
|
|
|
+ productMap.put(product.getPid(), product);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return productMap;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|