|
@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.caimei365.order.components.ProductService;
|
|
|
import com.caimei365.order.mapper.BaseMapper;
|
|
|
import com.caimei365.order.mapper.CartSellerMapper;
|
|
|
+import com.caimei365.order.mapper.OrderCommonMapper;
|
|
|
import com.caimei365.order.model.ResponseJson;
|
|
|
import com.caimei365.order.model.dto.AgainBuyDto;
|
|
|
import com.caimei365.order.model.dto.SellerCartDto;
|
|
@@ -17,6 +18,7 @@ import com.github.pagehelper.PageInfo;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.google.common.util.concurrent.AtomicDouble;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -46,6 +48,8 @@ public class CartSellerServiceImpl implements CartSellerService {
|
|
|
@Resource
|
|
|
private CartSellerMapper cartSellerMapper;
|
|
|
@Resource
|
|
|
+ private OrderCommonMapper orderCommonMapper;
|
|
|
+ @Resource
|
|
|
private ProductService productService;
|
|
|
|
|
|
/**
|
|
@@ -364,7 +368,8 @@ public class CartSellerServiceImpl implements CartSellerService {
|
|
|
AtomicDouble totalOriginalPrice = new AtomicDouble(0);
|
|
|
// 是否包含充值商品,默认false
|
|
|
AtomicBoolean includeRecharge = new AtomicBoolean(false);
|
|
|
-
|
|
|
+ //所有的商品数据
|
|
|
+ List<CartItemVo> totalProductList = new ArrayList<>();
|
|
|
// 促销活动(总)
|
|
|
List<PromotionsVo> totalPromotions = new ArrayList<>();
|
|
|
// 促销活动Id集合,用于合并促销活动
|
|
@@ -509,6 +514,7 @@ public class CartSellerServiceImpl implements CartSellerService {
|
|
|
// 商品种类
|
|
|
kindCount.updateAndGet(v -> v + shopKindCount.get());
|
|
|
}
|
|
|
+ totalProductList.addAll(productList);
|
|
|
}
|
|
|
// 供应商下商品种类
|
|
|
shop.setCount(shopKindCount.get());
|
|
@@ -556,6 +562,59 @@ public class CartSellerServiceImpl implements CartSellerService {
|
|
|
Double availableMoney = baseMapper.getAbleUserMoney(clubUserId);
|
|
|
// 可用采美豆
|
|
|
Integer userBeans = baseMapper.getUserBeans(clubUserId);
|
|
|
+
|
|
|
+ //优惠券相关信息
|
|
|
+ List<CouponVo> couponList = orderCommonMapper.getClubCouponList(clubUserId);
|
|
|
+ Iterator<CouponVo> iterator = couponList.iterator();
|
|
|
+ while (iterator.hasNext()) {
|
|
|
+ CouponVo coupon = iterator.next();
|
|
|
+ BigDecimal totalAmount = BigDecimal.ZERO;
|
|
|
+ Integer couponType = coupon.getCouponType();
|
|
|
+ for (CartItemVo item : totalProductList) {
|
|
|
+ if (couponType == 0) {
|
|
|
+ if (coupon.getProductType() == 1) {
|
|
|
+ //活动券-全商城商品
|
|
|
+ BigDecimal price = MathUtil.mul(item.getPrice(), item.getNumber());
|
|
|
+ totalAmount = MathUtil.add(price, totalAmount);
|
|
|
+ } else if (coupon.getProductType() == 2) {
|
|
|
+ //活动券-指定商品
|
|
|
+ List<Integer> couponProductIds = orderCommonMapper.getCouponProductIds(coupon.getCouponId(), 2);
|
|
|
+ if (couponProductIds.contains(item.getProductId())) {
|
|
|
+ BigDecimal price = MathUtil.mul(item.getPrice(), item.getNumber());
|
|
|
+ totalAmount = MathUtil.add(price, totalAmount);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (couponType == 1) {
|
|
|
+ //品类券
|
|
|
+ if (coupon.getCategoryType().equals(item.getCommodityType())) {
|
|
|
+ BigDecimal price = MathUtil.mul(item.getPrice(), item.getNumber());
|
|
|
+ totalAmount = MathUtil.add(price, totalAmount);
|
|
|
+ }
|
|
|
+ } else if (couponType == 2 || couponType == 4) {
|
|
|
+ //用户专享券或新用户券
|
|
|
+ BigDecimal price = MathUtil.mul(item.getPrice(), item.getNumber());
|
|
|
+ totalAmount = MathUtil.add(price, totalAmount);
|
|
|
+ } else if (coupon.getCouponType() == 3 && coupon.getShopId() != null) {
|
|
|
+ //店铺券
|
|
|
+ String shopName = baseMapper.getShopNameById(coupon.getShopId());
|
|
|
+ if (StringUtils.isNotBlank(shopName)) {
|
|
|
+ if (shopName.length() > 7) {
|
|
|
+ shopName = shopName.substring(0, 6) + "...";
|
|
|
+ }
|
|
|
+ coupon.setShopName(shopName);
|
|
|
+ }
|
|
|
+ if (coupon.getShopId().equals(item.getShopId())) {
|
|
|
+ BigDecimal price = MathUtil.mul(item.getPrice(), item.getNumber());
|
|
|
+ totalAmount = MathUtil.add(price, totalAmount);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (MathUtil.compare(totalAmount, coupon.getTouchPrice()) < 0) {
|
|
|
+ iterator.remove();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ couponList.sort((o1, o2) -> o2.getCouponAmount().compareTo(o1.getCouponAmount()));
|
|
|
+
|
|
|
// 包装返回数据
|
|
|
Map<String, Object> resultData = new HashMap<>();
|
|
|
resultData.put("list", shopList);
|