|
@@ -13,6 +13,7 @@ import com.caimei365.order.model.dto.SellerCartDto;
|
|
|
import com.caimei365.order.model.po.SellerCartPo;
|
|
|
import com.caimei365.order.model.vo.*;
|
|
|
import com.caimei365.order.service.CartSellerService;
|
|
|
+import com.caimei365.order.utils.ImageUtil;
|
|
|
import com.caimei365.order.utils.MathUtil;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
@@ -302,6 +303,88 @@ public class CartSellerServiceImpl implements CartSellerService {
|
|
|
return ResponseJson.success(resultMap);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 协销购物车列表数据 -- 组织
|
|
|
+ *
|
|
|
+ * @param serviceProviderId 协销Id
|
|
|
+ * @param clubId 机构Id
|
|
|
+ * @param pageNum 页码
|
|
|
+ * @param pageSize 每页数量
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResponseJson<Map<String, Object>> getSellerCartOrganizeList(Integer serviceProviderId, Integer clubId, int pageNum, int pageSize) {
|
|
|
+ List<Integer> againBuyIdList = Lists.newArrayList();
|
|
|
+ // 失效商品列表(总)
|
|
|
+ List<CartItemVo> invalidList = new ArrayList<>();
|
|
|
+ // 开始分页请求供应商数据
|
|
|
+ PageHelper.startPage(pageNum, pageSize);
|
|
|
+ log.info("serviceProviderId, clubId"+serviceProviderId+"---"+clubId);
|
|
|
+ // 协销购物车供应商列表
|
|
|
+ List<CartShopVo> shopInfoList = cartSellerMapper.getSellerCartShops(serviceProviderId, clubId);
|
|
|
+ if (null != shopInfoList && shopInfoList.size() > 0) {
|
|
|
+ shopInfoList.removeIf(Objects::isNull);
|
|
|
+ // 遍历供应商列表
|
|
|
+ shopInfoList.forEach(shop -> {
|
|
|
+ // 默认未选中状态(前端要求)
|
|
|
+ shop.setIsChecked(false);
|
|
|
+ // 该供应商下商品种类
|
|
|
+ AtomicInteger shopKindCount = new AtomicInteger(0);
|
|
|
+ // 该供应商总价
|
|
|
+ AtomicDouble shopPrice = new AtomicDouble(0);
|
|
|
+
|
|
|
+ // 供应商下商品列表
|
|
|
+ List<CartItemVo> productList = cartSellerMapper.getSellerCartOrganizeProducts(serviceProviderId, clubId, shop.getShopId());
|
|
|
+ // 迭代器设置商品信息
|
|
|
+ Iterator<CartItemVo> productIterator = productList.iterator();
|
|
|
+ while (productIterator.hasNext()) {
|
|
|
+ CartItemVo cartItemVo = productIterator.next();
|
|
|
+ // 图片路径
|
|
|
+ String image = ImageUtil.getImageUrl("product", cartItemVo.getImage(), domain);
|
|
|
+ cartItemVo.setImage(image);
|
|
|
+ // 默认所有商品未选中状态(前端要求)
|
|
|
+ cartItemVo.setIsChecked(false);
|
|
|
+ // 设置skus
|
|
|
+ cartItemVo.setSkus(orderClubMapper.getOrganizeSku(cartItemVo.getProductId()));
|
|
|
+ if (cartItemVo.getValidFlag() == 2) {
|
|
|
+ // 后台逻辑删除,已停售
|
|
|
+ cartItemVo.setStatus(1);
|
|
|
+ invalidList.add(cartItemVo);
|
|
|
+ } else {
|
|
|
+ // 设置商品有效
|
|
|
+ cartItemVo.setStatus(0);
|
|
|
+
|
|
|
+ // 再来一单的商品前端默认勾选
|
|
|
+ if (againBuyIdList.contains(cartItemVo.getProductId())) {
|
|
|
+ cartItemVo.setIsChecked(true);
|
|
|
+ }
|
|
|
+ // 该供应商下商品种类 +1
|
|
|
+ shopKindCount.incrementAndGet();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 供应商商品
|
|
|
+ shop.setCartList(productList);
|
|
|
+ // 供应商总价
|
|
|
+ shop.setTotalPrice(shopPrice.get());
|
|
|
+ // 供应商下商品种类
|
|
|
+ shop.setCount(shopKindCount.get());
|
|
|
+ });
|
|
|
+ // 删除空数据
|
|
|
+ shopInfoList.removeIf(shop -> (null == shop || shop.getCount() == 0));
|
|
|
+ }
|
|
|
+ if (null == shopInfoList) {
|
|
|
+ shopInfoList = new ArrayList<>();
|
|
|
+ }
|
|
|
+ PageInfo<CartShopVo> pageInfo = new PageInfo(shopInfoList);
|
|
|
+ /*
|
|
|
+ * 返回结果
|
|
|
+ */
|
|
|
+ Map<String, Object> resultMap = new HashMap<>(2);
|
|
|
+ resultMap.put("pageDate", pageInfo);
|
|
|
+ resultMap.put("invalidProductList", invalidList);
|
|
|
+ // 返回数据
|
|
|
+ return ResponseJson.success(resultMap);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取协销购物车商品种类
|
|
|
*
|